This is a discussion on "Problem with DTHML Browser detection/redirection" within the Web Page Design section. This forum, and the thread "Problem with DTHML Browser detection/redirection are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
Problem with DTHML Browser detection/redirection
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Problem with DTHML Browser detection/redirection
I'm trying to get this DHTML browser detection redirection script to work for
MSIE browsers >= 6 and Netscape Browsers >= 6. I am using MSIE 6 and Netscape 7.1 to test these scripts under these conditions. This is the original script, which is to be placed in the head section of the html document: <script> //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) window.location.replace("http://mozilla.org") //if IE 4+ else if (browser_type=="Microsoft Internet Explorer"&&browser_version>=4) window.location.replace("http://microsoft.com") //if NS4+ else if (browser_type=="Netscape"&&browser_version>=4) window.location.replace("http://www.netscape.com") //Default goto page (NOT NS 4+ and NOT IE 4+) else window.location="http://www.dynamicdrive.com" </script> This actually works. But when I change it to this... <script> //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>=6) // Changed from >=5 to >= 6 window.location.replace("http://mozilla.org") //if IE 4+ else if (browser_type=="Microsoft Internet Explorer"&&browser_version>=6) // Changed from >=4 to >=6 window.location.replace("http://microsoft.com") //if NS4+ else if (browser_type=="Netscape"&&browser_version>=4) window.location.replace("http://www.netscape.com") //Default goto page (NOT NS 4+ and NOT IE 4+) else window.location="http://www.dynamicdrive.com" </script> ... The first test condition goes to www.netscape.com (not mozilla.org) and the second test condition goes to the last condition (dynamicdrive.com) Am I doing something wrong here? How do I get Netscape browsers >=6 and MSIE browsers >= 6 to go to the specified locations? Thanks! |
|
|
|
|||
|
Although you tested it with NS7.1, if you add the following line of code, you will see that your browser version is still version 5. This is why your script is not responding as you expect.
u2o |
|
|||
|
Good reason! Is that because of the happy people over at netscape then?? How can you detect for their browser when it won't tell you it's real version??
|
![]() |
| Tags |
| problem, dthml, browser, detectionredirection |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Browser detection IE mac | jillcary | JavaScript Forum | 1 | Aug 1st, 2007 11:28 |
| Browser css problem | saltedm8 | Web Page Design | 8 | Aug 17th, 2006 13:04 |
| Moock Detection Script Problem | opel | Flash & Multimedia Forum | 0 | Jan 18th, 2006 19:50 |
| Browser size detection?! | courtjester | Web Page Design | 1 | Aug 26th, 2004 07:03 |
| redirection problem | iamzoli | PHP Forum | 12 | Apr 11th, 2004 08:48 |