• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 3. Advanced DHTML Techniques > Delaying or Stopping an Action

Delaying or Stopping an Action

Generally when we start a dynamic action on a page by triggering a JavaScript function, we expect the action to take place immediately after the event that triggered it. Click the button and see the message. However, actions often need to be delayed by a few seconds or longer. For example, after clicking a drop-down menu, you may want it to pause briefly before automatically disappearing.

One way to force a pause would be to use a for loop to count a certain number of milliseconds. While this works, a more effective and versatile technique is to use the set-TimeOut() method. This is not only more compact, it also allows you to immediately trigger a function after the pause.


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint