Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2013
    Thanked 0 Times in 0 Posts

    Modify display position for script

    First I want to say that I am sort of a beginner with this and I need some help changing the position for a javascript tool tip.

    So, this is a script that displays a tooltip when hovering the cursor over a link.
    At the moment the tip is displayed beneath the link and I would like to appear above. Here is the positioning code:

    positiontip:function($, tipindex, e){
    		var anchor=this.anchors[tipindex]
    		var tooltip=this.tooltips[tipindex]
    		var scrollLeft=window.pageXOffset? window.pageXOffset : this.iebody.scrollLeft
    		var scrollTop=window.pageYOffset? window.pageYOffset : this.iebody.scrollTop
    		var docwidth=(window.innerWidth)? window.innerWidth-15 : htmltooltip.iebody.clientWidth-15
    		var docheight=(window.innerHeight)? window.innerHeight-18 : htmltooltip.iebody.clientHeight-15
    		var tipx=anchor.dimensions.offsetx
    		var tipy=anchor.dimensions.offsety+anchor.dimensions.h
    		tipx=(tipx+tooltip.dimensions.w-scrollLeft>docwidth)? tipx-tooltip.dimensions.w : tipx //account for right edge
    		tipy=(tipy+tooltip.dimensions.h-scrollTop>docheight)? tipy-tooltip.dimensions.h-anchor.dimensions.h : tipy //account for bottom edge
    		$(tooltip).css({left: tipx, top: tipy})
    I would greatly appreciate any help with this.

    Thank you,

  2. #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    London, England
    Thanked 2,599 Times in 2,577 Posts
    Change the values in this line to suit

    var docheight=(window.innerHeight)? window.innerHeight-18 : htmltooltip.iebody.clientHeight-15;

    Instead of -18 and -15 try +18 and +15 and see what you get. Adjust further if necessary.

    Quizmaster: This city in anagram form GIN JIBE has hosted the Summer Olympics. What is it?
    Contestant: Belgium.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


Posting Permissions

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