1

This might be a noob question. I need a script to redirect to URL and refresh that URL every 5 minutes.

i start with:

<!DOCTYPE html>
<html>
    <head>
        <title>Example</title>
        <script>
            function init()
            {
               window.location.href = "my URL";
            }
        </script>
    </head>

    <body onload="init()">
    </body>
</html>

it will open my URL, but if i try some refresh in meta tag, it doesnt working, i need refreshing that redirected URL.

Rambotnik
  • 15
  • 4

2 Answers2

0

I don''t really know what you need but i think this is:

    <script>
         function init() {
              var newWindow = window.open("http://mylink","_self");
                   //use _blank if you want it on a new tab
         }
    </script>
    <script>
         function reloadInterval() {
            location.reload();
            setTimeout(function(){
                          reloadInterval()
                       }, 300000)

         }
         function _interval() {
            reloadInterval()
         }
    </script>
    <img src="nosrc" alt="" onerror="reloadInterval()">

and instead of using onload use:

    <img src="onload-purposes" alt="" onerror="init()">

comment this question if you need anything else

MrPizzaGuy
  • 52
  • 13
0

You cannot execute JavaScript Code for foreign Websites. Imagine the security implications. (see this for further information: How to access another tab in Chrome in javascript?)

What might be a solution for you is to open the link every 5 minutes new and close the previous one. This would be done with an interval. But be careful, the interval will never stop...

var myWindow; // create global empty object
function openWindow(){
  myWindow = window.open("www.google.de"); // define the opened window in there
}

openWindow(); //actually open the new window
setInterval(function(){
  myWindow.close(); // close the specific window
  openWindow() // open the window again
},30000) // executed every 5 minutes (30000 ms)
Plemo
  • 51
  • 5