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!

Using JScript & JavaScript

Status
Not open for further replies.

shmmeee

Programmer
Apr 17, 2001
104
GB
I want to use a command that is JScript specific (try...catch) I also want to provide an alternative for non-IE browsers. Can I put them both in the same function with a browser detection script? (i.e: if(IE){try...catch}
else{someting else})
I've tried this and it isn't working so I'm guessing the answer is no. So how could I do this?
 
Here's a quick example that may help:
Code:
<html>
<head>
<script language=&quot;javascript&quot;>
function dothis() {
if (navigator.appName == &quot;Netscape&quot;) {
alert(&quot;Netscape&quot;)
}
else {
document.write(&quot;Internet Explorer&quot;)
}
}
</script>
</head>
<body>
<form>
<input type=&quot;button&quot; onclick=&quot;dothis()&quot; value=&quot;Test&quot; />
</form>
</body>
</html>

In Netscape it will alert you that it's Netscape and in IE it will write &quot;Internet Explorer&quot; on the page...
 
Ummm....that's not quite what I was asking, but it doesn't matter I've sorted it, thanks anyway :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top