我有一个正在尝试使用的测试 visualforce 页面。它只是一个带有 2 个按钮的空白页面,应该在 iframe 中打开 url。下面是我在页面后面的代码。
顶点类:
public class OnLoadController {
public String Page {get; set;}
public String OpenPageURL {get; set;}
public void OnLoadController()
{
Page = '' ;
OpenPageURL = '' ;
}
public PageReference redirect()
{
if(Page == 'google')
{
OpenPageURL = 'http://www.google.com' ;
}
if(Page == 'mpay')
{
OpenPageURL = 'http://www.yahoo.com/' ;
}
return null;
}
}
视觉力量页面:
<apex:page id="pg" controller="OnLoadController">
<apex:form>
<apex:actionFunction action="{!redirect}" name="OpenPage" reRender="pb,theIframe">
<apex:param assignTo="{!Page}" value="" name="param1"/>
</apex:actionFunction>
<apex:pageBlock id="pb">
<apex:pageBlockButtons>
<apex:commandButton value="Google" onclick="OpenPage('google'); return false;"/>
<apex:commandButton value="Yahoo" onclick="OpenPage('blog'); return false;"/>
</apex:pageBlockButtons>
<apex:iframe id="theIframe" src="{!OpenPageURL}" scrolling="true"/>
</apex:pageBlock>
</apex:form>
</apex:page>
页面加载正常,按钮显示完美,但是当我点击它们时没有任何反应。我只想能够单击按钮并在页面的 iframe 中打开 url。