tags:

views:

26

answers:

1
<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 function is called from within the bottom frame

+1  A: 

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.

Pekka
it doesn't work. i tried javascript console. this is what i get Unsafe JavaScript attempt to access frame with URL http://205.177.170.156/test/bin-release/index.htm from frame with URL http://sample.com/. Domains, protocols and ports must match.
Vivek Chandraprakash
@Vivek that's a new error. Try `.src` instead of `location`, e.g. `window.frames.topFrame.src ="..."` you can't modify a document that's not on your domain.
Pekka
i found the issue. it was because the second frame was using a location in a different domain. thanks a lot
Vivek Chandraprakash
@Pekka - "Every browser has a JavaScript error console" - I think you'll find the one in IE6 -) unless of course you install the web developer toolbar, debug bar or similar. That said, indeed the console is the first place to check (when available).
scunliffe