Hi, I have this code from once existed site sohtanaka.com which got hacked and now doesn't exist anymore (has highly effected many people who used to follow it). Well I am not able to understand how to make the tooltip appear next to my mouse pointer, in the script below there are many widths and heights. Not even that there are + (plus sign) and - (minus sign). So its confusing me, If someone could explain the co-ordinates, so I could use it properly. If I have to be more specific I am not able to understand these four lines of code all other is understandable var mousex = e.pageX + 50; //Get X coodrinates var mousey = e.pageY - 340; //Get Y coordinates Code (markup): and these two if ( tipVisX < 90 ) { //If tooltip exceeds the X coordinate of viewport mousex = e.pageX - tipWidth - 90; } if ( tipVisY < 90 ) { //If tooltip exceeds the Y coordinate of viewport mousey = e.pageY - tipHeight - 90; } Code (markup): <script type="text/javascript"> $(document).ready(function() { //Tooltips $(".tip_trigger").hover(function(){ tip = $(this).find('.tip'); tip.show(); //Show tooltip }, function() { tip.hide(); //Hide tooltip }).mousemove(function(e) { var mousex = e.pageX + 50; //Get X coodrinates var mousey = e.pageY - 340; //Get Y coordinates var tipWidth = tip.width(); //Find width of tooltip var tipHeight = tip.height(); //Find height of tooltip //Distance of element from the right edge of viewport var tipVisX = $(window).width() - (mousex + tipWidth); //Distance of element from the bottom of viewport var tipVisY = $(window).height() - (mousey + tipHeight); if ( tipVisX < 90 ) { //If tooltip exceeds the X coordinate of viewport mousex = e.pageX - tipWidth - 90; } if ( tipVisY < 90 ) { //If tooltip exceeds the Y coordinate of viewport mousey = e.pageY - tipHeight - 90; } //Absolute position the tooltip according to mouse position tip.css({ top: mousey, left: mousex }); }); }); </script> Code (markup):
First, I think you post miss box. Second, your script have function that can find where is mouse pointing (by get X,Y). After that, function will calculate to place where tips box will appear. (belong to windows width and height) and set CSS for tip with two css properties top and left. That's all. I think evthing is ready to use, no need to do more about this. Do you have ever code with jQuery?