Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Feb 2009
    Posts
    101
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Is there a way to display a pop-up after a set time?

    Hi all,

    I'm looking to implement a small popup on my site, but it'll only show after a certain set time & then automatically fade after a set time.

    Is there a way to achieve this? Looking for a javascript or jquery solution (primarily looking to solve the timer part).

    thanks

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Do you have code for your popup already (like a DIV with some styling)?

    Let's assume you have a DIV with ID "popup" and style="display: none;". Then you need two functions. The following code uses jQuery
    Code:
    var certainTimeInSec = 5;
    
    function showPopup() {
       $('#popup').fadeIn(1000);
       window.setTimeout(hidePopup, certainTimeInSec * 1000);
    }
    
    function hidePopup() {
       $('#popup').fadeOut(1000);
    }
    
    $(function() {
       window.setTimeout(showPopup, certainTimeInSec * 1000);
    });

  • Users who have thanked devnull69 for this post:

    SlyOne (05-04-2011)

  • #3
    Regular Coder
    Join Date
    Feb 2009
    Posts
    101
    Thanks
    7
    Thanked 0 Times in 0 Posts
    hi Devnull,

    no, i don't have the styling yet, that won't be a problem. it was more a case if there were a simple light weight solution without too much development resource... and there is, thanks to you!

    i'll give your code a whirl, looks like it should do the trick.


    thanks again


  •  

    Posting Permissions

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