...

View Full Version : switching a frame on loadup



tpeck
02-24-2003, 07:18 AM
Hi. I have a frameset with three frames: called top, middle and bottom.

The contents of the bottom frame only work properly in the Explorer browser, so I have an alternative frame with contents that work fine in Netscape.

What I would like is to use javascript to check which browser is loading the frameset and choose the appropriate bottom frame to load.

From my experiments it seems the code should reside between the <head> tags in the bottom frame itself, not the frames page HTML (true?).

I have:

<script language="JavaScript">
//-->
function netscape4() {

var whoAmI = navigator.appName;
var whatAmI = parseInt(navigator.appVersion.charAt(0));

if (whoAmI == "Netscape" && whatAmI == 4) {
top.frames['bottom'].location=(netscapesafe.html');
}

}
// End -->
</script>

<body onload="netscape4()">

I assume it is the ......... top.frames['bottom'].location=(netscapesafe.html'); .......... line which is not working, but I've tried every combination of javascript words known to man, and no swopping in of the correct frame.

What am I doing wrong?

Thanks

Terry

arnyinc
02-24-2003, 01:50 PM
I'm not so good with framesets, but I noticed a missing apostrophe in that line you think might be causing the problem. I don't think the parentheses matter, but I guess it won't hurt to keep them.

top.frames['bottom'].location=(netscapesafe.html');

should be

top.frames['bottom'].location=('netscapesafe.html');

tpeck
02-24-2003, 10:31 PM
Thanks so much arnyinc,

I think the missing apostrophe was only in my posting, but GUESS WHAT? I have solved my own problem!

I should have been using:

self.location('netscapesafe.html');

I discovered it by accident just by trying out all the combinations of javascript words (it took about 3 days...)

I think this is really useful - it means I can switch in a version of page or a frame that is specific for a browser (when you just CAN"T get something to render properly).

OK - the full working code for a frame or page that is compatible with, say, Netscape 4 is:

**********************************

<script language="JavaScript">
//-->
function netscape4() {

var whoAmI = navigator.appName;
var whatAmI = parseInt(navigator.appVersion.charAt(0));

if (whoAmI == "Netscape" && whatAmI == 4) {
self.location=('netscapesafe.html');
}

}
// End -->
</script>

<body onload="netscape4()">

**********************************

Place it on the page or frame that won't render properly in Netscape 4 and the 'netscape4.html' page/frame will load into it!

SOLVED!

Terry



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum