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

JavaScript that works in IE and Opera but not NN or FF???

Status
Not open for further replies.

Luke2500

Programmer
Sep 19, 2005
2
GB
This script works fine for IE and Opera but not at all in NN and FF. Any suggestions, please. Thankyou.

<!--
var Netscape, MSIE, Opera, Unknown;
var Win, Mac, Other;

Netscape = navigator.appName == "Netscape";
MSIE = navigator.appName == "Microsoft Internet Explorer";
Opera = navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Opera") > -1;
Firefox = navigator.appName == "Microsoft Internet Explorer" && navigator.userAgent.indexOf("Firefox") > -1;
Unknown = !(Netscape || MSIE || Opera || Firefox);

Win = navigator.userAgent.indexOf("Win") > -1;
Mac = navigator.userAgent.indexOf("Mac") > -1;
Other = !(Win || Mac);

if (Netscape)
{
alert("Netscape")
}
else if (Firefox)
{
alert("Firefox")
}
else if (Opera)
{
alert("Opera")
}
else if (MSIE)
{
alert("Explorer")
}
/-->
 
Just in-case anyone can't figure it out I just did... I missed a / of the end...

All that for the sake of /--> instead of //-->

I guess I should validate more.... stupid *kicks himself*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top