View Full Version : BROWSER REDIRECT -- IE w/ IFRAME

12-12-2002, 04:13 AM
"Browser Redirect Script" from DD (http://www.dynamicdrive.com/dynamicindex9/bredirect.htm) ... in the process of modifying for my needs. I can't get the IE line to work. It's supposed to stay on the page in which I place this script, and load the iframe should it be necessary -- such as with www.website.com/services/index.html?someservice.html -- where someservice.html will load in the iframe. I'm getting errors with the portion in bold. No, I don't "know" JavaScript. But, I follow along from time to time. I await your reply and/or solution(s). Thanks!


//Browser redirect Script- Dynamic Drive (www.dynamicdrive.com)
//For full source code, 100's more DHTML scripts, and Terms Of Use,
//visit dynamicdrive.com

var browser_type=navigator.appName
var browser_version=parseInt(navigator.appVersion)

//if NS 6
if (browser_type=="Netscape"&&browser_version>=5)
//if IE 4+
else if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4)
{ window.frames['content'].location = window.location.search.slice(1); }
//if NS4+
else if (browser_type=="Netscape"&&browser_version>=4)
//Default goto page (NOT NS 4+ and NOT IE 4+)

Below is what I started to type in this post. I thought it might be easy for one of you to add in an N6 spec in the following body onload statement. So, feel free to answer this if applicable. THANKS.

I have the following browser checker to redirect N4 users to an alternalte page. How can I make N6 users go to the same page!?

<body onload="if(document.layers){window.location='index_n4.html'} else { if (window.location.search) { window.frames['content'].location = window.location.search.slice(1); } }">

The else part loads an iframe (if applicable). I know N6 can normally handle iframes, but not the way I'm doing it. So, I need it redirected.

12-14-2002, 12:42 AM
I hate bumping my own threads. I really do!

But, I thought this problem wouldn't be too difficult for y'all. Just (please) take a look at the bold part above and tell me how to fix it.

Thanks! :thumbsup:

12-17-2002, 03:13 AM

Okay, I guess I've stumped all of you again. Sorry to be so pissy, but after a long day's work (stress), I really needed a nice bonus tonight.

I guess I'll bump this last time -- so I don't get in trouble.

12-17-2002, 03:25 AM
you can't access an iframe (or any form element for that matter) when it is NOT LOADED yet in the page.

12-17-2002, 04:49 AM
Thanks for the reply glenngv...I was hoping someone like yourself might drop by.

Okay, so how can I adapt (if at all) the <BODY> line below into a browser redirection script? The <body> line below currently works...and redirects N4 users. I need it to also redirect N6 users.

Anything else that will simulate this...and give me the same results!?

<body onload="if(document.layers){window.location='index_n4.html'} else { if (window.location.search) { window.frames['content'].location = window.location.search.slice(1); } }">

12-17-2002, 05:13 AM
if you want to redirect ns4 and ns6 to the same page:

<body onload="if(document.layers || (document.getElementById && !document.all)){window.location='index_n4.html'} else { if (window.location.search) { window.frames['content'].location = window.location.search.slice(1); } }">

if you want to redirect on a different page:

<body onload="if(document.layers){window.location='index_n4.html'} else if (document.getElementById && !document.all){window.location='index_n6.html'} else { if (window.location.search) { window.frames['content'].location = window.location.search.slice(1); } }">

you might want to put it in a function so that it's more readable

12-18-2002, 02:32 AM
THANKS, glenngv!
you might want to put it in a function so that it's more readableWell, I'd be happy to try out other code, but I'm unable to write it. What you've given me works! If you or anyone else wants to write something more stable, by all means post your creations. Thanks again!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum