window.myframeid.location.href无法使用谷歌浏览器

时间:2014-08-27 15:10:16

标签: javascript google-chrome iframe frameset

我有一个使用iframe的页面。在其下面有一个框架,有两个框架。其中一个帧ID是myframeid。这是代码段。

<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但不适用于谷歌浏览器版本36.当我使用IE 11浏览器点击按钮时,该功能正常工作。但不是谷歌铬。我认为谷歌浏览器不像下面的代码。

 window.myframeid.location.href = '/code/cgi/bin';

任何想法为什么?谢谢!

1 个答案:

答案 0 :(得分:0)

myframeid是一个ID,您可以使用document.getElementById('myframeid')获取参考。您可以通过设置其src属性来加载新页面。

相关问题