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

  • Home
  • SEARCH
  • 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 4099882
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T20:29:40+00:00 2026-05-20T20:29:40+00:00

I have a site, now what I want is when user switch to some

  • 0

I have a site, now what I want is when user switch to some external site, then an Ad should be popped up, and also when user close the browser window, the Ad should get popup, I have used onunload, but it shows the message on clicking every link, and also I used on beforeunload, it does almost everything, but it do the same as onunload…

Please anyone have some idea how should I achieve this?

  • 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-05-20T20:29:40+00:00Added an answer on May 20, 2026 at 8:29 pm

    This doesn’t prevent popup appearing on page refresh, but does this job as requested:

    <script>
    var isLinkClicked = false;
    
    // Either plain JS solution:
    var links = document.getElementsByTagName('a');
    var l=links.length;
    while (l--) {
        links[l].addEventListener("click", function() {
           isLinkClicked = true;
        }, false);
    } 
    
    // Or jQuery solution:
    $("a").live("click", function() {
           isLinkClicked = true;
    });
    
    
    // And then Unload event listener:
    window.addEventListener("unload", function(evt) {
        if (isLinkClicked) {
           isLinkClicked = false;
           return false;
        }
    
        // here comes the rest of the code
    }, false);
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have a site hosted on example.com , now I want each of
I have a soap request returning array of User objects. Now I want to
I'm working on a site now that have to fetch users feeds. But how
I was already running a sub-website under following path http://example.com/sub-site/ Now, I have created
I migrate from Joomla to WordPress my web site and now I have many
I have a membership site in beta right now... At the moment, when a
Right now I have a Drupal site where I'm integrating a custom front-end interface
I have a web site that spits out links to third party sites. Now
I have developed a site with ASP.NET MVC 1, and now I'm trying to
Right now we have AD/Exchange to manage all of our users logins/e-mail on-site at

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.