cyberspy
asked on
Need code for detecting OS?
Hi everyone,
I am wondering if there's any code for detecting an operating system that the user is using? Let's say if a user goes to a specific webpage I want it to detect his OS and then depending if it's Windows or Mac to redirect him to another appropriate page. Is that possible? If yes, please help me out with the script. I really appreciate it.
--
cyberspy.
I am wondering if there's any code for detecting an operating system that the user is using? Let's say if a user goes to a specific webpage I want it to detect his OS and then depending if it's Windows or Mac to redirect him to another appropriate page. Is that possible? If yes, please help me out with the script. I really appreciate it.
--
cyberspy.
ASKER
Thanks for your reply. Only one question, what is the difference between mac.html and index_mac.html?
You explained in e.g. parts of redirecting for Mac and windows and then just redirecting? please explain me the last one. Thanks.
You explained in e.g. parts of redirecting for Mac and windows and then just redirecting? please explain me the last one. Thanks.
the last one guarantees a redirection, either to the page for Macs or Windows. The function provided is flexible enuff for that.
ASKER
Ok, I just tried it and it didn't work. I place this code in my index.html page and specified index.html for windows redirect and mindex.html for mac redirect and it didn't work. I'm not sure why...?
the code Brandon provided was client side, i can offer a server side function if you support ASP?
BRUNO
BRUNO
ASKER
No, client side is fine, but it didn't work when I opened the page on Mac, it stayed on the index.html page. How can I get it to work? Please help me out.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
That worked just fine, Thanks BRUNO:)!!
Glad I could help! Thanks for the A. :-)
//general redirection
function redirectPage(szWinURL,szMa
if (navigator.userAgent.match
if (szMacURL.length != 0) window.location.replace(sz
} else {
if (szWinURL.length != 0) window.location.replace(sz
}
}
//e.g. of redirecting if Macs are found
redirectPage("","mac.html"
//e.g. of redirecting if window is found (default)
redirectPage("win.html",""
//e.g. redirecting
redirectPage("index_win.ht
</script>