Click to See Complete Forum and Search --> : javascript redirect for only one type of user?!?!
kelly002
01-18-2003, 06:21 PM
I need a javascript that would allow when my page is loaded to directly redirect all Mac users using IE5 only to a different page. All other users would need to stay on the page they just loaded. Can someone help me out or point me towards a tutorial/script to do this?
kelly002
01-18-2003, 08:49 PM
names are even more deceiving than looks sometimes Dave. This is all I can say. It's not the first time I get that one. lol
Anyway, I'm confused where to place that javascript. You said in the body?
The body tag for the page is
<body bgcolor="#000000" text="#000000" link="#000000" vlink="#000000" alink="#000000" scroll="auto" ONLOAD="preloadImages();">
Do I need to place it in there? Can't seem to get it to work right. I'm pretty new to the whole javascript world so any clarification would be much appreciated.
Would this be correct syntax?
<body bgcolor="#000000" text="#000000" link="#000000" vlink="#000000" alink="#000000" scroll="auto" ONLOAD="preloadImages();" onload="
if (!document.all
&& navigator.userAgent.toLowerCase().indexOf('mac')!=(-1)) {
top.location.href = "infos.html";
}
">
Thanks!
kelly002
01-19-2003, 08:47 AM
can't get it to give me that alert. I must be missing something when I put the script in the <head>. ?!?!?
kelly002
01-19-2003, 09:05 AM
here we go for that info then...
4.0 (compatible, MSIE 5.0; Macintosh; 1; PPC)
thanks!
kelly002
01-19-2003, 09:45 AM
Dave,
thanks so much for your help. this works great! Just one litle question will this works regardless of which version of Mac IE5 the user is using. Meaning 5.0 ; 5.1.4 ; 5.1.3 ?
thanks again!
kelly002
01-19-2003, 04:22 PM
awesome. this is exactly the kind of script that I was lookign for!!! Thanks!
Is there an easy reverse script which I could put on the the mac IE5 users page to keep all other users off (those who aren't mac and using IE5.) Just in case a different user ended up on the Mac IE5. page, he would be automatically redirected to the other original page. Is this possible without getting too complicated?
kelly002
01-19-2003, 05:44 PM
well, I figured it had something to do with else but I just don't know how to code in this language. I understand what it does when I read it but I just can't write the code myself. I guess one day, I'll learn. Maybe.
Do you know how you tell if a blonde used your computer?
||
||
\/
If there's lipstick on the joystick.
Thanks for the code and sorry about the bad joke.
kelly002
01-21-2003, 06:18 PM
as someone suggested to me, replacing:
top.location.href = "page_for_MAC_IE_users.html";
to read like this:
top.location.replace("page_for_MAC_IE_users.html");
prevents the Back Button from being "broke" for the visitor. Figured I'd share that little tip.