Search code examples
javascriptjqueryjgrowl

Displaying a jgrowl message after X seconds?


I'm implementing jgrowl on my website, but did not find any indication on the plugin's website nor on the internet on how to display the message with a lag. Ideally I'd like the Jgrowl message to appear 10 seconds after the page loads. Is it possible?

<script type="text/javascript">
  $(function () {   
    if($.cookie("new_visitor") != "true") {
        $.cookie("new_visitor", "true", { expires: 1, path: '/' });
        $.jGrowl("A message with a header", { header: 'Important' });
    }
  });
</script>

Solution

  • exactly what the others said. See it in code.

    $(function () { 
        if($.cookie("new_visitor") !== "true") {
    
            $.cookie("new_visitor", "true", { expires: 1, path: '/' });
    
            setTimeout(function(){
                $.jGrowl("A message with a header", { header: 'Important' });
            },10000);  // display after 10 seconds
        }
    });