Results 1 to 5 of 5

Thread: Doevents in JS?!?!?!?!

  1. #1

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538

    Lightbulb Doevents in JS?!?!?!?!

    Hi everyone! I've got this code which is called to scroll my div tag.
    Code:
    function ScrollDIVDown()
    {
    	blnKeepScrolling = true;
    	while (blnKeepScrolling = true)
    	{
    		document.getElementById('divToScroll').scrollTop = 
    		document.getElementById('divToScroll').scrollTop + intScrollIncrement;
    	}
    }
    Now this one's called when the user hovers their mouse over an image, when the mouseout event of the same image occurs, I'm trying to alter the variable & therefore exit the loop - but the loop keeps on continuing and the mouseout event never gets fired! Is there a better way to do this please, or is there a JS doevents equivalent?
    Code:
    <IMG SRC="images/ScrollArrow_Up.jpg" onmouseover="Javascript: ScrollDIVDown()"
    onmouseout="javascript: blnKeepScrolling=false;">
    Thanks!!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  2. #2
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    change
    while (blnKeepScrolling = true)
    to
    while (blnKeepScrolling == true)

    I assume blnKeepScrolling is global

  3. #3

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Drat missed that one - thanks for spotting that! unfortunatley though, this doesn't make it work though....

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

  4. #4
    Frenzied Member DeadEyes's Avatar
    Join Date
    Jul 2002
    Posts
    1,196
    Then I assume the onMouseout won't get fired until the onmouseOver function has finished, and this won't finish because it's in an infinite loop.
    Within the ScrollDIVDown function's loop is there a way to check if the mouse is over the image and if not exit loop.

  5. #5

    Thread Starter
    Evil Genius alex_read's Avatar
    Join Date
    May 2000
    Location
    Espoo, Finland
    Posts
    5,538
    Guess I could do an event check function, yep will check this out thanks!

    Please rate this post if it was useful for you!
    Please try to search before creating a new post,
    Please format code using [ code ][ /code ], and
    Post sample code, error details & problem details

Posting Permissions

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



Click Here to Expand Forum to Full Width