Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IE error handling

    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?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    try something like this

    var agt = navigator.userAgent.toLowerCase();

    if(agt.indexOf("msie")==-1) {

    ... not IE

    }

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #4
    New Coder
    Join Date
    Jul 2002
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •