Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8321681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T23:06:13+00:00 2026-06-08T23:06:13+00:00

I need a bit of help with this javascript code. I have this code:

  • 0

I need a bit of help with this javascript code.

I have this code:

jQuery(document).ready(function(){
    if (document.cookie.indexOf('visited=true') == -1) {
    var fifteenDays = 1000*60*60*24*1;
    var expires = new Date((new Date()).valueOf() + fifteenDays);
    document.cookie = "visited=true;expires=" + expires.toUTCString();
    window.setTimeout(
function() {
    jQuery.colorbox({href:"/popup.htm", open:true, iframe:false, innerWidth:600, innerHeight:490}); 
        },

30000 )}});   

It’s supposed to open a popup after 30 seconds, one time per day. The issue is that the popup it’s opening after 30 seconds on stay on a page. It’s there any way to make it to open after 30 seconds even if the client navigate to other page ? So, if the user stay 15 seconds on a page and 15 on another, getting the popup.

Thank you in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T23:06:15+00:00Added an answer on June 8, 2026 at 11:06 pm

    The fundamental issue to overcome here is passing the ‘state’ between pages. Since you’re already using cookies in your example, we’ll work with that. You need to set a session cookie with the time the user has been on the site (initially 0). You’d then need to ‘poll’ the cookie once every so often (every 5 seconds maybe) to update the total time on site count, and read it back. If it’s 30 seconds or more, fire the popup.

    So instead of using:

    setTimeout(function() {
        // open alert box
    }, 30000);
    

    You’d do something like:

    setTimeout(function() {
        // Increment 'time-on-site' cookie value by 5000
        // Then, if 'time-on-site' cookie value >= 30000, fire popup
    }, 5000);
    

    UPDATE
    Of course, this requires a lot more back-and-forth to the server, as you need to communicate the updated value every 5 seconds.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help understanding this bit of code pre { white-space: pre; white-space:
I need a bit of help with some Ruby array jujitsu. I have the
I have an HTML Document that looks a bit like this, only is far
I need some help with floating point numbers...please! Here's the thing, I have code
need a bit of help. I have an XML with a list of cities
I need a bit of help from any of the coders out there..... Currently,
I need a bit of help; I'm helping a friend port a Delphi app
I don't know MySQL very well so I need a bit of help with
I need a wee bit of help with css formatting on my website. Please
I'm a SQL noob, and I need a little bit of help understanding the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.