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 3 of 3

Thread: if NS6 or IE

  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    40
    Thanks
    4
    Thanked 1 Time in 1 Post

    if NS6 or IE

    I’m using the tooltip scripts from:

    http://www.dynamicdrive.com/dynamici...mltooltip2.htm

    The main entry function for displaying the tip is:

    Code:
    function ddrivetip(thetext, thewidth, thecolor){
      if (ns6||ie){
        if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
        if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
        tipobj.innerHTML=thetext
        enabletip=true
        return false
      }
    }
    This code runs file on IE8 and FF12. It defiantly executes the code inside the test for NS6 and IE, I changed the innerHTML to set it to “Yabba Dabba Doo” and all the tips came up with that phrase.

    How does FF know it is NS6 or IE so it can execute the code? Is the if statement really necessary?

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    You have only posted part of the script. The ns6 and ie values are being set elsewhere in the script.

    That it is doing that at all indicates that what you have is an antiquated script that should have been completely rewritten about five years ago - presumably the ie is referring to IE4 since if the ns6 test is set up correctly it would include IE5+.

    As far as that particular piece of code is concerned you can simply remove the if statement and run the code within it all the time. Presumably tipobj is incorrectly defined as a global object as otherwise the script wouldn't work.

    The rest of the script probably needs similar minor changes to get rid of the worst of the antiquated unnecessary code and a complete rewrite to fix all the other potential problems.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #3
    New Coder
    Join Date
    Jul 2011
    Posts
    40
    Thanks
    4
    Thanked 1 Time in 1 Post
    Duh, anther old age brain #@&!

    Sorry for wasting everyone's time.

    By the way, the script works great. I'll post the page I'm using it for as soon as it is ready.


  •  

    Posting Permissions

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