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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browser Sniffing

Status
Not open for further replies.

jackyl

Programmer
Oct 23, 2001
44
CA
(I'm sure this has been answered already, but the seach is down)

I have a bit of coding that does not work with older browsers ...

SO ...

I need to write a bit of code for the older browsers (specifically Netscape 4.7) ... and have it run the new code if the user is using NN 4.7, or run the oher code I have if they have newer browsers.

Any help?

J...
 
What kind of code are we talking about??
Generally speaking a browser sniffer code might look like this:
Code:
<script>
function browseSniff() {
  if(navigator.appName == &quot;Netscape&quot; && navigator.appVersion > &quot;6&quot;) {
    alert(&quot;Sorry, but this site requires Internet Explorer or Netscape 6+&quot;);
  }
}	
</script>
This will throw an alert if the users browser is NS4x...you can tweak this code for what you need...simply add your code, or call your function in place of calling the alert() tag...
Something like this:
Code:
<script>
function tellall() {
  if(navigator.appName == &quot;Netscape&quot; && navigator.appVersion == &quot;4x&quot;) {
    function1;  
  }
  else (
    function2;
  }
}	
</script>
I have not failed; I have merely found 100,000 different ways of not succeding...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top