开发者

this javascript is not working in chrome but works in ie

<script language="javascript">


function switchScreen(v)
{

if(v=='d')
{
    mf.rows="0,*";
    window.frames.topFrame.location='blank.htm';

}
else
{
    mf.rows="*,0";
    window.frames.topFrame.location='http://sample.htm';


}


}



</script>


<frameset name="mf" id="mainFrame" rows="*,0" frameborder=no framespacing=0>
<frame name='topFrame' id="tp" src='http://sample.htm/' scrolling="no" frameborder=0 noresize marginheight=0 marginwidth=0>
<frame name='bottomFrame' id="bp" src='Main.html' scrolling="no" frameborder=0 noresize  marginheight=0 marginwidth=0>
</frameset>

The开发者_如何学Go function is called from within the bottom frame


In this case, mf will be available in Internet Explorer only, because that browser has the "feature" of adding all DOM elements with a name to the window object.

Add

mf = document.getElementById("mainFrame");

to the top of the script and it will work.

By the way, to see JavaScript errors in Chrome, press Ctrl + Shift + J and then the "Console" tab. Every browser has a JavaScript error console, which should always be the first port of call when something doesn't work; it's just a bit hidden sometimes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜