0

我有一个正在尝试使用的测试 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。

4

1 回答 1

0

您的 apex 代码和 visualforce 都可以,但您需要查看浏览器控制台,您可以在其中找到以下错误:

' https://c.ap1.visual.force.com/apex/test ' 的页面是通过 HTTPS 加载的,但运行了来自 ' http://www.yahoo.com/ ' 的不安全内容:该内容也应该是通过 HTTPS 加载。

修复此错误后,您将面临以下错误:

拒绝在框架中显示“ https://www.google.com/?gws_rd=cr&ei=IhiYUoCsOcWdhAedlIKwDg ”,因为它将“X-Frame-Options”设置为“SAMEORIGIN”。

如您所知,这是安全问题。

这个页面可以正常工作OpenPageURL = 'http://www.youtube.com/embed/' ;

于 2013-12-03T18:01:37.527 回答