Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

redirect page depending on browser type?

Status
Not open for further replies.

taval

Programmer
Jul 19, 2000
192
GB
How do you redirect to another site/page depending on what browser/browser version the user is using. This is bacause I have a site with iframes that do not work on older versions of netscape?

Grateful for any help, Thanks.
[sig][/sig]
 
There are many ways of doing this. The simplest is the following...


Code:
<html>
<script language=&quot;javascript&quot;>
var chkIE = document.all

if (chkIE) window.location=&quot;[URL unfurl="true"]http://www.microsoft.com&quot;[/URL]
else window.location=&quot;[URL unfurl="true"]http://www.netscape.com&quot;[/URL]
</script>
</html>

You could also check for document.layers for NN. Except for the most simple applications I don't recommend the above. A better and more configurable way is below...

Code:
<html>
<script language=&quot;javascript&quot;>
var browser = navigator.appName;
var version = navigator.appVersion

alert (&quot;Browser: &quot; + browser + &quot;\nVersion: &quot; + version);

var regExp = /Internet\sExplorer/gi
if (browser.search(regExp)>0) window.location=&quot;[URL unfurl="true"]http://www.microsoft.com&quot;[/URL]
else window.location=&quot;[URL unfurl="true"]http://www.netscape.com&quot;[/URL]
</script>
</html>

Hope this helps, [sig]<p>Rob<br><a href=mailto:robschultz@yahoo.com>robschultz@yahoo.com</a><br>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br>
"Focus on the solution to the problem,<br>
not the obstacles in the way."<br>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~[/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top