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 7552833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:53:09+00:00 2026-05-30T10:53:09+00:00

I am using a Javascript redirect to redirect visitors after X seconds. However, there

  • 0

I am using a Javascript redirect to redirect visitors after X seconds. However, there is also a link on the page that takes the visitor to the same page. I would like to stop the redirection if the visitors clicks on the link first.

Please note that ,the link is opening in the new window when clicked but the javascript redirect opens in the same window.

This is the code am using in my HTML Page ,

Javascript redirect code:

<script>
<!-- 
timeout = '5000'; // milliseconds/1000th of a sec
window.onload = setTimeout(myRedirect, timeout); // ensure we load the whole page

function myRedirect() {

window.location = "http://www.mypage.com/page1.html";
}
//-->
</script>

and there is this link which opens in new window:

<a href="http://www.mypage.com/page2.php" target="_blank">Click Here</a>

any ideas on how i can 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-30T10:53:10+00:00Added an answer on May 30, 2026 at 10:53 am

    store your timeout call in a variable.

    var timeout = '5000';
    var myTimeout;
    window.onload = function(){
        myTimeout = setTimeout(myRedirect, timeout);
    }
    

    and when you want it cancelled, clear that timeout in that variable:

    clearTimeout(myTimeout)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to redirect a page using javascript output using php. The problem I'm
When I refresh a page or redirect to the same one using the same
I need to redirect to a page using javascript/jquery. I have a page with
Is there a difference between me using Javascript to redirect to URL + ?Querystring=value
How to redirect to a particular link if checkbox is checked using javascript? I
Is it possible to attach a file using mailto: redirect in javascript? Something like
Using JavaScript, how do I create an HTML table that can "accept" numeric matrix
Without using Javascript, is there a way to make a CSS property toggle on
I need to edit (using javascript) an SVG document embedded in an html page.
I am trying to redirect one url using JavaScript for passing values to Java

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.