PDA

View Full Version : Cross-browser script...


Wolf_22
08-30-2005, 01:48 AM
Here's the script:


<html>
<head>
<title></title>
<script>
if(navigator.userAgent.indexOf("Firefox") != -1)
{
window.location = "secondLayer/indexFF.htm";
}
else if(navigator.userAgent.indexOf("MSIE") != -1)
{
window.location = "secondLayer/indexIE.htm";
}
else if(navigator.userAgent.indexOf("Netscape") != -1)
{
window.location = "secondLayer/indexNS.htm";
}
else
{
window.location = "secondLayer/indexX.htm";
}
</script>
</head>
<body>
<p>Please wait while the browser redirects you...</p>
</body>
</html>



Can Opera be included into this script too? I tried it just by copy and pasting the "else if" and inserting "Opera" as a value that was being passed. Can someone help me out with this please?

Thanks

BaldEagle
08-30-2005, 01:59 AM
Opera identifies itself as IE, however read this:

http://www.betanews.com/article/Opera_to_Stop_Spoofing_IE_User_Agent/1122911404

BaldEagle

Wolf_22
08-30-2005, 02:05 AM
Interesting... So does that mean then that by downloading the 8.02 version that the script that I'm using will recognize Opera?

BaldEagle
08-30-2005, 02:15 AM
I do not know for certain but I assume that if you include that (Opera) in your browser sniffer code you will be covered for the old (those that are saying they are IE) and the new (Opera). Just my take on it, perhaps a more browser aware person could answer that better (maybe someone that uses and keeps up with Opera).

BaldEagle

Wolf_22
08-30-2005, 02:24 AM
Anyone else think that I could do this???

(Thanks BaldEagle)

Wolf_22
08-30-2005, 02:27 AM
Okay, I just inserted my theory inside my code and downloaded the Opera and tried it, and it didn't seem to work as it directed me to the IE part of it... :confused:
So anyone have any ideas?

What is the script that I need???

Wolf_22
08-30-2005, 02:33 AM
Okay, I think I just found out why it wasn't working...

The "indexOf" object is only compatitble with browsers "NN4-7", "IE4-6".

Well, that solves that!

(I found this answer in "The Web Programmers Desk Reference" by Lazaro Issi Cohen and Joseph Issi Cohen)