dhtml / javascript problems. Seeking help.

Results 1 to 2 of 2

Thread: dhtml / javascript problems. Seeking help.

  1. #1
    Tom Levesque Guest

    Default dhtml / javascript problems. Seeking help.

    I am defining my &#060;div&#062; tag, floatBox, like this:<BR><BR>#floatBox{<BR> <BR>position : absolute;<BR>height : 10px;<BR>width : 10px;<BR>left : 50;<BR>top : 0;<BR>border : 5px solid black;<BR>background-color : green;<BR>layer-background-color : green;<BR>visibility : hidden;<BR><BR>}<BR><BR>Now, I have a &#060;script&#062; which attempts to move the floatbox whenever the onMouseMove event happens:<BR><BR>document.write(&#039&#060;div id="floatBox"&#062;Test&#060;/div&#062;&#039);<BR><BR>var box = document.all(&#039floatbox&#039);<BR><BR>function floatBox(){<BR> <BR>var x = window.event.clientX;<BR>var y = window.event.clientY; <BR> <BR>box.style.top = y + 15;<BR>box.style.left = x + 15;<BR>box.style.visibility = "visible"; <BR>}<BR> <BR>document.onmousemove = setTimeout("floatBox();",100);<BR><BR>I want it to "trail" behind my cursor. That&#039s what the setTimeout() is for. This script works PERFECTLY except for one little minor problem. The "onmousemove" event does NOT get passed via a setTimeout() and as a result the window.event.clientx/y produces an error because "window.event" is no longer an object -- the "onmousemove" "event" happened 100 milliseconds ago. Any suggestions here? Perhaps as to another way I can get the current cursor coordinates without using window.event. <BR><BR>I only want this to work in IE. I can&#039t stand working with dhtml in NN anyway, it&#039s a major pain in the ***. Maybe one day Netscape will hire some real programmers, until then Netscape can kiss my *** and that of every other website developer out there. :)<BR><BR>I&#039m in a good mood today, trust me. I&#039ve been fiddling with an SQL database all morning. Trying to get a huge ASP application to work all afternoon. I "missed" break, lunch and break again then I stayed about an hour overtime. Then I find out that my huge ASP application DOESNT work in Netscape yet it does in IE which I find strange because obviously ASP is server side. This meant that is was an HTML problem which meant I had to go through line by line and ..... nevermind............ just fix my problem, someone. :)

  2. #2
    jason Guest

    Default RE: dhtml / javascript problems. Seeking help.

    try passing the coordinates as arguments to the function<BR><BR>i.e. onmousemove = setTimeout(&#039floatBox(&#039+ window.event.clientX + &#039, &#039 = window.event.clientY + &#039)&#039, 100)<BR><BR>then it won&#039t metter if the event object exists or not. may or may not work (i haven&#039t tested it), but sounds convincing eh?<BR><BR>jason

Posting Permissions

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