【发布时间】:2014-08-27 15:10:16
【问题描述】:
我有一个使用 iframe 的页面。下面有一个框架集,它有两个框架。其中一个框架 ID 是 myframeid。这是代码sn-p。
<html>
<head></head>
<body>
<iframe name="someiframe" src="/app/html/files">
<html>
<head></head>
<body>
<script>
function thismyfunction(dObj, dTo, dCode){
if (dTo == 'start'){
if (tempora) {
if (confirm('Is this correct?')){
window.myframeid.location.href = '/code/cgi/bin';
}
} else {
if (confirm('Prefer to view your account?')){
window.myframeid.location.href = '/code/welcome/account';
} }
}
}
</script>
<frameset cols="30%, 70%" FRAMEBORDER=NO FRAMESPACING=0 BORDER=0>
<frame name="someframe" id="topframe" src="/app/source/default.htm" scrolling="no">
<frame name="someframe2" id="myframeid" src="/app/html/load">
<input type="button" onclick="parent.thismyfunction(this.form, 'start')"
id="nicebutton" value="Hello world" />
</frameset>
</body>
</head>
</html>
</iframe>
</body>
</head>
</html>
这适用于 IE 11,但不适用于 google chrome 版本 36。当我使用 IE 11 浏览器单击按钮时,该功能有效。但不在谷歌浏览器中。我认为谷歌浏览器不喜欢下面的代码。
window.myframeid.location.href = '/code/cgi/bin';
任何想法为什么?谢谢!
【问题讨论】:
-
你检查过,哪个对象
window.myframeid在 Chrome 中吗?请注意,上述框架的id是"right"而不是"myframeid"。 -
很高兴找到@Teemu!谢谢!!我编辑了页面。这是我发布问题时的错误。
-
我怀疑这会解决您的问题,这只是问题中的文本和代码之间的冲突。
window.name应该引用框架内的window对象。它在 Chrome 中吗? -
请在尝试设置其
location对象的href之前输入console.log(window.myframeid)。然后打开控制台刷新页面点击按钮,你看到了什么? -
@Teemu 看来函数无法访问 myframeid。不是吗?
标签: javascript google-chrome iframe frameset