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 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Reload just once

    How can I reload a page when it comes up just Once.

    I tried this in my metatags:
    Code:
    <Meta http-equiv="refresh" Content="10;URL=http://pageurlhere/">
    and I also tried this way:
    Code:
    <script>
    document.location.reload(true);
    </script>
    Both reload my page continuesly like it is in a loop. Please advise how I can get the page to reload/refesh just Once after it loads.

  • #2
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,278
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Why do you need to reload the page just once when it first comes up? If your intention is to ensure that the content is updated and not cached then you should just use meta tags to prevent caching of pages.
    Spookster
    CodingForums Supreme Overlord
    All Hail Spookster

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried this with my metatags and it didnt work:

    Code:
    <meta http-equiv="cache-control" content="no-cache, must-revalidate"> 
    <meta http-equiv="pragma" content="nocache">
    Any other way to prevent caching of pages??

  • #4
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try:
    Code:
    <script type="text/javascript" language="javascript">
    
    if (self.name != '_refreshed_')
    {
        self.name = '_refreshed_';
        self.location.reload(true);
    }
    else self.name = '';
    
    </script>
    [untested]
    &nbsp;........ another wild guess ........

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks cheesebag it works in Netscape! For some reason it doesnt work in IE. Also what is '_refreshed_'???


    After using what you wrote and it worked in Netscape only I tried the following to try and get it to work in IE but no luck:

    Code:
    <script type="text/javascript" language="javascript">
    NS4=document.layers
    if(NS4)
    {
    if (self.name != '_refreshed_')
    {
    self.name ='_refreshed_';
    self.location.reload(true);
    }
    else self.name = '';
    }
    else
    {
    if (self.name != '_refreshed_')
    {
    self.name ='_refreshed_';
    self.location.refresh(true);  //used IE refresh command here
    }
    else self.name = '';
    }
    }
    
    
    </script>

  • #6
    Regular Coder
    Join Date
    Aug 2003
    Posts
    383
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hmm...just tested (IE6, NS7, Moz Firebird), works everywhere. '_refreshed_' is just a string - use anything distinctive - used to name the window (self) temporarily so, when the page reloads, the reload won't execute again. Hope you're not in a frameset here (named windows).

    location.reload() fine in MSIE...
    &nbsp;........ another wild guess ........

  • #7
    Regular Coder
    Join Date
    Jul 2002
    Posts
    362
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for all your help and information and correcting my problem.

    I am using IE 5.5.


  •  

    Posting Permissions

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