Refresh only once

1

I'm building a website and need a strength.

The problem is this: I need to enter the same as a refresh , just when I enter it

I tried the code:

<meta http-equiv="refresh" content="1">

However, it gets in looping infinite refresh and I need this to occur only once.

    
asked by anonymous 28.09.2018 / 19:45

3 answers

0

I do not think it's a good solution to do a refresh right after accessing the site.

But you can use the command:

location.reload();
    
28.09.2018 / 20:16
0

You can create a function and apply a condition.

    window.onload = function() {
    if(!window.location.hash) {
        window.location = window.location + '#carregar';
        window.location.reload();
    }
}
    
28.09.2018 / 20:08
0

If there is no other way to correct your problem ... or until you find a solution ....

javascript step by step

  • get the page url
  • Check if there are any parameters in the url
  • If there is no make redirect to the page itself by adding a parameter.
  • Parameter redirection will not execute the script

    var url=window.location.href;
    var parametrosDaUrl = url.split("?")[1];
    
    if (!parametrosDaUrl){
    
       window.location = "parametrosDaUrl.html?stop=yes";
    
    }
    
  • 28.09.2018 / 22:39