SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trubble with screen possiton (x,y) with popup..

    Hello!
    Im currently working on a webpage and Im having a little trubble with a javascript im using on the site.
    The script makes popup boxex come up when I move the cursor over a link and if the cursor is draged outside the link, or the popupbox it will fade away after a little while..

    When I Apply the script on a empty homepage, like test.htm with this sctipt only and some test links it works just fine.. but when trying to use it on my webpage at work I get "Error On page, line 112" and that "X" is undefined.. Seems like he cant read out x or y to get the screen possistone..

    My code:

    if (document.layers) {navigator.family = "nn4";}
    if (document.getElementById) {navigator.family = "dom";}

    // ############## POPUP TEXT ARRAY
    descarray = new Array(
    'You can put in a really long<br>description if it is nessary to<br>explain something in detail,<br>like a warning about content<br>or privacy.',
    'Lastly, you can have links like thesebr><a target="_top" href="http://javascript.internet.com/">JavaScript Source<\/a><br><a target="_top" href="http://javascript.internet.com/">JavaScript Source<\/a><br><a target="_top" href="http://javascript.internet.com/">JavaScript Source<\/a><br>With a change in the onmouseout event handler.');
    overdiv="0";
    // ######### CREATES POP UP BOXES
    function popLayer(a){
    if(!descarray[a]) {
    descarray[a]='<span class="pop">This popup (#'+a+') needs description text!<\/span>';
    }
    desc = "<table class='pop' summary='*'>\n<tr class='pop'><td class='pop'>\n";
    desc +=descarray[a];
    desc +="<\/td><\/tr><\/table>";

    document.getElementById("object1").innerHTML=desc;
    document.getElementById("object1").style.left=x+15;
    document.getElementById("object1").style.top=y-5;

    }

    function hideLayer(){
    if (overdiv == "0") {
    document.getElementById("object1").style.top="-500";}
    }

    // ######## TRACKS MOUSE POSITION FOR POPUP PLACEMENT
    var isNav = (navigator.appName.indexOf("Netscape") !=-1);
    function handlerMM(e){
    x = (isNav) ? e.pageX : event.clientX + document.body.scrollLeft;
    y = (isNav) ? e.pageY : event.clientY + document.body.scrollTop;
    }
    if (isNav){document.captureEvents(Event.MOUSEMOVE);}
    document.onmousemove = handlerMM;

    I made the text red where the x,y cordinates are, or should be then the javascript is runned.. but dosent seem to work.. please some one help me!!
    :-(

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2004
    Posts
    1,647
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where have u defined x and y????
    and u cant use...
    Code:
    var bla = x + 15;
    it will display the x definition and the number 15....
    u have to use..
    Code:
    var bla = parseInt(x) + 15;
    i hope it helps...
    cheers


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
  •