Passing Arguments in Firefox != IE? BAH!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • isoquin
    New Member
    • Jul 2007
    • 48

    #1

    Passing Arguments in Firefox != IE? BAH!

    Goal: Div which moves to mouse position, and has contents changed.

    This seems to work ok in IE (with the exception of the div being slightly higher then the mouse for some reason?), but doesn't work at all in FF. In fact, even a basic argument pass doesn't seem to work. I've been looking around the net as to why this is happening. Here's my code - please direct me to the apropriate tutorial or offer pointers - thank you.

    [code=javascript]function details(e, contents)
    {
    var mouseX = 0;
    var mouseY = 0;
    var obj = document.getEle mentById('detai l');


    if (!e) e = window.event;

    if (document.all)
    {
    mouseX = event.clientX + document.body.s crollLeft;
    mouseY = event.clientY + document.body.s crollTop;
    }
    else
    {
    mouseX = e.pageX;
    mouseY = e.pageY;
    }

    obj.style.left = mouseX + 'px';
    obj.style.top = mouseY + 'px';

    obj.innerHTML = '<b>Details:</b> ' + contents;[/code]

    FF claims "contents" is undefined, while IE works fine and reads the string I pass to the function.

    also, alert(mouseX + " and " + mouseY) = "undefined and undefined"

    Other error console errors in FF:
    Error in parsing value for property 'left'. Declaration dropped.
    Error in parsing value for property 'top'. Declaration dropped.

    Previously I also had "e has no properties". Why do all arguments seem to be undefined in FF?

    Again, help is greatly appreciated. Thank you.
    Last edited by acoder; Sep 23 '07, 11:51 AM. Reason: Added language to code tag
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    How are you calling details()?

    Comment

    Working...