下午帮忙看了一个web问题,index.html中嵌入<iframe>来加载同文件目录下的一个页面,在多个浏览器下测试,发现IE浏览器中会出现问题,<iframe>不能正常加载,显示空白页,右键属性为"_blank" 。
一开始,想到的是src属性的问题,可能是路径不对,但是经过不同浏览器测试,不存在路径问题。
单独把src路径拿出来,贴到IE浏览器中,发现页面加载没问题。通过分析,问题应该出现在index.html文件中,单独的<iframe>加载ok,通过排除法,就是Index.html文件中某些代码出现了问题,使得IE浏览器发飙了。
然后,上网找寻答案,有很多很多的帖子在问相关问题,也有很多人开博写这种问题的解决办法,大概罗列如下:
1.IE浏览器的bug,<iframe>标签的src属性不要放到第一位,因为这样会诱发IE的bug.
2.采用动态创建dom节点的方式,来创建<iframe>动态加载页面。
后来经过大勇的测试发现,将index.html页面头部的<!--saved from url=(0022)http://www.yoururl.com -->代码去掉之后,页面加载问题解决了,但是这行代码的作用何在?
这也是解决了本问题的一个方案,经过查阅资料,这行代码的用途是IE下安全验证的一个设置,来控制是否会弹出黄色的消息提示框,来提醒你是否允许此Active运行在客户端。
- <span style="font-size:18px;">To allow active content or scripting to run in a web page without the
- Information Bar appearing, you can add "Mark of the Web" code,
- so that the file is run in a zone other than the Local Machine zone,
- for example the Internet zone or the Intranet zone.
- The following code is an example of a Mark of the Web:
- <!-- saved from url=(0022)http://www.yoururl.com -->
- To include the code above in your projects, change the URL
- to point to your domain, and change the number (0022) to the
- correct number for your domain. This number indicates
- how many characters are in your domain name (beginning with
- the "h" in "http", and ending with the last letter of your domain;
- for example, the "m" in ".com").
- A generic way of writing the Mark of the Web code is as follows:
- <!-- saved from url=(0014)about:internet -->
- about:internet will place the page in the Internet zone,
- allowing the page to bypass the Local Machine zone lockdown. </span>
此代码是用来控制哪些用户访问时不会提示验证提示框,而我们如何跳过这个设置,来运行我们的web项目呢?
我们可以远程预览页面或者在本地部署iis/tomcat服务器来运行项目,这样就可以在IE下正常加载<iframe>页面,并且不影响安全性验证提醒。