View Full Version : Resolved Browser redirect for IE 5 not working

02-12-2010, 02:19 AM
Hello forum! This script is supposed to redirect IE 5 to a page on my site.
However, the code is not doing the redirect part.
Take a look:

OLDIE - or Old IE. A script that finds the version of IE you're using,
and redirects if lower than the set parameter.
[[ Created by Ryan McLaughlin, www.DaoByDesign.com ]]
var browser = navigator.appName
var ver = navigator.appVersion
var thestart = parseFloat(ver.indexOf("MSIE"))+1 //This finds the start of the MS version string.
var brow_ver = parseFloat(ver.substring(thestart+4,thestart+7))

if ((browser=="Microsoft Internet Explorer") && (brow_ver < 5)) //Change to suite
window.location="../oldie.html"; //URL to redirect to.

I also would like to point out that the code belongs in a .js file.
NOT <script type="javascript".........

Old Pedant
02-12-2010, 03:34 AM
MSIE 5 might insist on seeing location.href instead of just location.

Did you test it with an alert() to see if it's getting to that line???

02-12-2010, 03:57 AM
Erm no, and I dont really know how to do that alert thing :confused:
Oh and that wasnt me who made the script

02-12-2010, 04:00 AM
if ((browser=="Microsoft Internet Explorer") && (brow_ver < 5)) //Change to suite
alert("FrickenTrevor got this far in my script");
window.location="../oldie.html"; //URL to redirect to.

02-12-2010, 04:14 AM
Sorry mapleleaf, but theres no alert that came up
I used IE 5.5 to test it.
Still lost btw :confused:

02-12-2010, 04:28 AM
Then this query:

if ((browser=="Microsoft Internet Explorer") && (brow_ver < 5)) //Change to suite

most likely doesn’t return “true”, i. e. the browser doesn’t identify itself in the way the script is looking for it.

Hm, it just occurs to me… You seem to be looking for IE lower than version 5 (brow_ver < 5). What happens if you change that to brow_ver < 6?

02-12-2010, 04:54 AM
It worls!!! :eek:
Thanks VIPStephan! :D

I took this

if ((browser=="Microsoft Internet Explorer") && (brow_ver < 5))
and changed the 5 to a 6 and now it works, alert and everything! :thumbsup:

thans for every one who helped :cool: