SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: tool tips

  1. #1
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    tool tips

    I'm looking for a simple tool tip script. I have tried a few, most recently one from http://dynamicdrive.com/dynamicindex5/dhtmltooltip.htm.

    Questions:
    1) Why do they recommend installing this script below the body tag and not linked to externally from withing the head area as most java scripts?

    2) Why do the tool tips position ithemselves erratically, not according to configuration settings?
    Code:
    var offsetxpoint=-10 //Customize x offset of tooltip
    var offsetypoint=-20 //Customize y offset of tooltip
    You can see current behavior and the full code in source view here:
    http://www.clickbasics.com/measure.php

    3) Can anyone recommend a simpler, more intuitive script?
    Last edited by paulcj2; Aug 6, 2008 at 19:16. Reason: tweaked copy
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,676
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    The advice about placing scripts at the end of the body tag (not below it) is sound advice. It speeds up the loading of the web page, and makes it easier to target page elements.
    http://developer.yahoo.com/performance/rules.html

    Most people place scripts in the head because that's the only way they've been taught.

    You should not place scripts inline on your html page. Always keep them in external script files.

    Here's the basic construct for how they should be organised.

    Code html4strict:
    <html>
    <head>
        <title>Test</title>
        <script src="js/moveToBottomIfPossible.js"></script>
    </head>
    <body>
    ...
    <script src="js/file.js"></script>
    </body>
    </html>
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have moved the script to the end of the body tag, and all seems well.

    I'm still wondering why the tool tips position themselves the way they do no matter what changes I make to the configuration settings:
    Code:
    var offsetxpoint=-10 //Customize x offset of tooltip
    var offsetypoint=-20 //Customize y offset of tooltip
    Originally the offsetxpoint had a value of -60. I tried to get it closer to the cursor by setting it to -10. However, this seemed to change nothing. I cleared my cache--even rebooted my computer. What am I missing?
    Paul C.
    ClickBasics
    http://www.clickbasics.com

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,676
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Works for me in both FF and IE when I make changes to their demo

    Is the page referencing the script file that has those changes made? has the changed script file been uploaded to the server? What checks can be performed to ensure that the web page is actually getting the updated script.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    Web Enthusiast
    Join Date
    Jul 2000
    Location
    Western Massachusetts, USA
    Posts
    1,381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Works fine now. I was confused by the way the values work. When I changed the x value from -60 to -20, the tool tip did not move to the left, as I expected it to. However, when I changed it to a higher negative number (now -200) it moved closer to to the cursor tip. Seems wierd to me, but it works. The y value is now 0, and that works for me, too.
    Paul C.
    ClickBasics
    http://www.clickbasics.com


Bookmarks

Posting Permissions

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