flex-iframe error: This content cannot be displaye

2019-09-05 14:01发布

问题:

I have a simple flex application that I created for testing. I download "flex-iframe-1.4.6.zip" library and using this library I am trying to display a url. But it does not show the web page instead it shows an error: "This content cannot be displayed in a frame".

<flexiframe:IFrame id="mapIFrame" visible="true" 
    source="http://www.google.com" width="500" height="500" label="Google"/>

How can I solve this problem?

回答1:

The message "This content cannot be displayed in a frame" is coming from Internet Explorer.

See IE8 Security Part VII: ClickJacking Defenses:

Web developers can send a HTTP response header named X-FRAME-OPTIONS with HTML pages to restrict how the page may be framed. If the X-FRAME-OPTIONS value contains the token DENY, IE8 will prevent the page from rendering if it will be contained within a frame. If the value contains the token SAMEORIGIN, IE will block rendering only if the origin of the top level-browsing-context is different than the origin of the content containing the X-FRAME-OPTIONS directive.

google.com`s current response header contains: X-Frame-Options: SAMEORIGIN

So the answer is: you can't use http://www.google.com in an iframe.

Accordingly, the example in the flex-iframe users guide is outdated (last edit 2 years ago).