Javascript google chrome iframe body onLoad不工作?
编辑:确实有效(抱歉)。此脚本中的某些内容导致它在google chrome中停止:Javascript google chrome iframe body onLoad不工作?,javascript,google-chrome,iframe,onload,Javascript,Google Chrome,Iframe,Onload,编辑:确实有效(抱歉)。此脚本中的某些内容导致它在google chrome中停止: function checkLocation() { var loc = top.location.href; var suffix = "subpage.html"; if (loc.indexOf(suffix, loc.length - suffix.length) !== -1) { top.location.href = "index.html"; } } 原创帖子: 我
function checkLocation() {
var loc = top.location.href;
var suffix = "subpage.html";
if (loc.indexOf(suffix, loc.length - suffix.length) !== -1) {
top.location.href = "index.html";
}
}
原创帖子:
我已经安装了IE 9、FF 3.6.3、Chrome(18.0.1025.151)和Safari 5.1.5
这适用于除google chrome之外的所有浏览器
我有一个HTML布局,其中包含一个命名的iframe。iframe src将更改以显示不同的页面。在其中一个页面上,我有一个脚本,它被加载到body标记的onLoad中。当页面仅在GoogleChrome中加载到iframe时,此脚本不会加载—在其他浏览器中它工作正常。此外,如果我直接将页面加载到google chrome中(而不是通过iframe),它也可以正常工作
我该如何解决这个问题
下面是一个示例代码:
index.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html> <head> <title> Example Page </title> </head>
<body> <a href="subpage.html" target="targetFrame">View subpage</a><BR/>
<iframe name="targetFrame"> </iframe>
</body>
</html>
subpage.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html> <head> <title> Subpage </title>
<script type="text/javascript" src="subpage.js"> </script>
</head>
<body onLoad="initialise()"> Hello </body>
</html>
subpage.js
function initialise() {
alert("Script loaded.");
}
index.html
示例页
subpage.html
子页面
你好
子页面.js
函数初始化(){
警报(“已加载脚本”);
}
感谢您的关注。原来这只是一个安全例外
Unsafe JavaScript attempt to access frame
with URL file:///C:/Users/.../website/index.html
from frame
with URL file:///C:/Users/.../website/subfolder/subpage.html.
Domains, protocols and ports must match.
一旦它上线,就应该没问题了