dispatching an event using setTimeout

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Apr 2007
Posts: 25
Reputation: jmasta is an unknown quantity at this point 
Solved Threads: 0
jmasta jmasta is offline Offline
Light Poster

dispatching an event using setTimeout

 
0
  #1
Jan 6th, 2009
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.
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 25
Reputation: jmasta is an unknown quantity at this point 
Solved Threads: 0
jmasta jmasta is offline Offline
Light Poster

Re: dispatching an event using setTimeout

 
0
  #2
Jan 6th, 2009
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!
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC