self.location problem

Posted on 2007-08-11
Last Modified: 2012-06-27
I have a web title page that I display for 5 seconds and then re-direct using the following code:

redirtime = "5000";
redirurl = "";
function redirtimer()
self.setTimeout("self.location.href = redirurl;",redirtime);

When I had Windows XP everything worked fine.  Now that I have Vista, when it re-directs, it leaves the original page open and opens a new page for "main.asp".  I only want one page.

Is there a solution for this problem?
Question by:deross
    LVL 11

    Expert Comment

    Try this:
    function redirtimer()
    setTimeout("location.href = redirurl;",redirtime);

    Author Comment

    This didn't work.
    LVL 17

    Expert Comment

    Here my function is similiar to BraveBrain's in that I use setTimeout and window.location.href (notice I explicitly used window).  I added 'var' to the variable declarations, and I made them local variables to make my example concise.  This worked just fine in Firefox 2.0 on my Mac.

    function redirtimer() {
      var redirtime = 5000;
      var redirurl = '';
      setTimeout( 'window.location.href = redirurl;', redirtime);

    If this doesn't work I would like to help some more but I would need the answer to these questions:
    1) What browser are you using?
    2) In what context and how do you make the call to your redirtimer function?
    3) Are you sure that the URL is correct?

    I think that should work though,
    - Joe P
    LVL 11

    Accepted Solution

    I'll add another question to those ;)

    4) Is there any particular reason you don't use a meta refresh?
    If no, the syntax would then be
    <meta http-equiv="Refresh" content="5; URL=" />
    in the head section of your page.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
    In my daily work (mainly using, I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now