View Full Version : IE error handling
florida
08-23-2002, 02:21 PM
Aug 23, 2002
I am trying to eliminate a button to not show up in IE because it only works in Netscape and I dont want it to show up in a IE browser but it should show up in a Netscape browser.
My attempt at it is not working:
if (navigator.appName != "Microsoft Internet Explorer")
{
<input type=button name=again value="Workstation Info (Netscape only)" onclick="display()"></td>
}
Any suggestions?
brothercake
08-23-2002, 03:19 PM
try something like this
var agt = navigator.userAgent.toLowerCase();
if(agt.indexOf("msie")==-1) {
... not IE
}
florida
08-23-2002, 03:45 PM
Where do I put the conditional part?
<SCRIPT LANGUAGE="JavaScript">
var agt = navigator.userAgent.toLowerCase();
if(agt.indexOf("msie")==-1) {
???
}
</script>
I have a bunch of table info here and then my last part of the table here:
<tr>
<td colspan=2 align=center>
<input type=button name=again value="Workstation Info (Netscape only)" onclick="display()"></td>
</tr>
</table>
</form>
HappyDude
08-23-2002, 06:22 PM
if (navigator.appName != "Microsoft Internet Explorer")
{
<input type=button name=again value="Workstation Info (Netscape only)" onclick="display()"></td>
}
Well, the main problem with this code is that you're trying to write HTML tags inside a <script> tag... either that or you're writing javascript without a <script> tag at all...
This should do what you're looking for:
<tr>
<td colspan=2 align=center>
<SCRIPT>
if (!document.all) //Using object detection to check if it's IE...
{
document.write('<input type="button" name="again" value="Workstation Info (Netscape only)" onclick="display()"></td>')
}
</SCRIPT>
</tr>
</table>
</form>
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.