SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: alert message

  1. #1
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    alert message

    Requirement: I want to show alert message to user after 5 minutes and after 9 minutes after page loading

    I use setTimeOut function .l...but it seems its throwing alerts repetitively. Is it a repetitive function ? Can you please suggest a solution to my requirement ?

  2. #2
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,890
    Mentioned
    211 Post(s)
    Tagged
    12 Thread(s)
    setTimeOut should only fire once.

    Here's an example using jQuery:
    Code JavaScript:
    $(document).ready(function() {
      setTimeout(function(){alert("Fired after ten seconds");}, 10000);
      setTimeout(function(){alert("Fired after twenty seconds");}, 20000);
    });

    In this example you should see two alert boxes (after ten and twenty seconds respectively).

  3. #3
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,788
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    Herew's the same example ithout jQuery

    Code:
    setTimeout(function(){alert("Fired after ten seconds");}, 10000);  
    setTimeout(function(){alert("Fired after twenty seconds");}, 20000);
    Note that the second alert may not fire if the person viewing the first alert checks the option to turn off JavaScript.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  4. #4
    Gre aus'm Pott gold trophysilver trophybronze trophy
    Pullo's Avatar
    Join Date
    Jun 2007
    Location
    Germany
    Posts
    5,890
    Mentioned
    211 Post(s)
    Tagged
    12 Thread(s)
    Quote Originally Posted by felgall View Post
    Herew's the same example ithout jQuery
    +1 for the reminder that jQuery is JavaScript.


Bookmarks

Posting Permissions

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