943,862 Members | Top Members by Rank

Ad:
Jan 6th, 2009
0

dispatching an event using setTimeout

Expand Post »
Hello everyone, I've ran into something that's been confusing me. Here's my code snippet:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. if (parent.scrollTop < parent.scrollHeight)
  2. {
  3. if(document.fireEvent){ //IE
  4. setTimeout("document.fireEvent('onmousemove')", 10);
  5. }else{ //FF
  6. var changeEvent = document.createEvent("MouseEvents")
  7. changeEvent.initEvent("mousemove", true, true);
  8. setTimeout("document.dispatchEvent(changeEvent)", 10);
  9. }
  10. }
What happens in Firefox is when the setTimeout fires, it tells me that changeEvent is undefined. To me, it seems to be defined. Has anyone run into this before and know how to work around it?
Thank you,
Last edited by jmasta; Jan 6th, 2009 at 1:13 pm.
Reputation Points: 10
Solved Threads: 0
Light Poster
jmasta is offline Offline
26 posts
since Apr 2007
Jan 6th, 2009
0

Re: dispatching an event using setTimeout

After doing some googling, I found this thread:
http://www.daniweb.com/forums/thread102251.html
which was very similar to mine. I tried ~s.o.s~'s suggestion and it worked very well, and I learned a little bit more about setTimeout. Thank you!
Reputation Points: 10
Solved Threads: 0
Light Poster
jmasta is offline Offline
26 posts
since Apr 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: Function to find prime numbers
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Tutorial On Creating Powerful Layouts





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC