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 TouchToneTommy 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...

 
Here it goes... Hope this will help you...

<SCRIPT LANGUAGE=&quot;JavaScript&quot;>
var useragent = navigator.userAgent;
var bName = (useragent.indexOf('Opera') > -1) ? 'Opera' : navigator.appName;

var pos = useragent.indexOf('MSIE');
if (pos > -1) {
bVer = useragent.substring(pos + 5);
var pos = bVer.indexOf(';');
var bVer = bVer.substring(0,pos);
}

/* var pos = useragent.indexOf('Opera');
if (pos > -1) {
bVer = useragent.substring(pos + 6);
var pos = bVer.indexOf(' ');
var bVer = bVer.substring(0, pos);
}

if (bName == &quot;Netscape&quot;) {
var bVer = useragent.substring(8);
var pos = bVer.indexOf(' ');
var bVer = bVer.substring(0, pos);
}

if (bName == &quot;Netscape&quot; && parseInt(navigator.appVersion) >= 5) {
var pos = useragent.lastIndexOf('/');
var bVer = useragent.substring(pos + 1);
}

document.writeln('<b>Browser Name: </b>' + bName + '<br>');
document.writeln('<b>Browser Version: </b>' + bVer + '<br>'); */


if (bVer==&quot;6.0&quot;){
document.write('');
}else{
document.write('');
}

// End -->
</script>
 
Thank you ...

one question now ...

I have this as one of the document write bits

if (bVer==&quot;6.0&quot;){
document.write('<table cellpadding=0 cellspacing=0 border=0><tr><td height=&quot;22&quot; width=&quot;157&quot;><img src=&quot;image/spacer.gif&quot; width=&quot;148&quot; height=&quot;1&quot; alt=&quot;&quot; border=&quot;0&quot;></td> </tr><tr><td height=&quot;1&quot; bgcolor=&quot;FFFFFF&quot;><img src=&quot;image/spacer.gif&quot; width=&quot;1&quot; height=&quot;1&quot; alt=&quot;&quot; border=&quot;0&quot;></td></tr><tr><td height=&quot;22&quot; width=&quot;157&quot; onClick=&quot;document.location='newLocation.htm'&quot; onmouseover=&quot;this.className='cell_overmain';&quot; onmouseout=&quot;this.className='cell_outmain';&quot; class=&quot;nav&quot;>
&nbsp;&nbsp;&nbsp;About the HKCBA</td></tr></table>');}

I think it's the onclick bits that's giving me difficulties now ...

any suggestions?
 
Hi Jackyl-

You have to substititute the single quote (') around newLocation.htm, cell_overmain and cell_outmain with &quot;
like shown below:

onClick=&quot;document.location=&quot;newLocation.htm&quot;&quot; onmouseover=&quot;this.className=&quot;cell_overmain&quot;&quot; onmouseout=&quot;this.className=&quot;cell_outmain&quot;&quot; class=&quot;nav&quot;

If you put a single quote anywhere else apart the end of your document.write statement the javascript interpreter in the browser will take that as the end of your document.write statement...

If you need more help I'm on Yahoo Messenger as placidopollicino...

Ciao
 
sorry Jackyl for the other posting the character is:
& q u o t ; (remove spaces)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top