0

I want to open a url in a new tab and refresh it using the other tab, so i'll never log out of the page! for this purpose i wrote this in the console of my browser to open a new tab and refresh it every ten seconds:

win1 = window.open("https://www.example.com"); //opens the page
timer1 = setInterval(function(){win1.location.href="https://www.example.com"},10*1000); //refreshes every 10 Sec.

The problem with this approach is that it kind of reopens the url rather than refreshing the page, and as long as it happens i log out of the site. I've read that there's a difference between hitting F5 and retyping the url in address bar and hitting Enter. and it looks like that the mentioned code doesn't really trigger the F5 kind of action i expected. so any idea on how can i truly refresh the other tab??

  • Why don't you fire a MouseEvent or KeyboardEvent rather than reloading the page? The other issue you'll run into is the document's focus status. Many sites test `document.hasStatus()` in order to defeat exactly what you are attempting. Good luck. – Randy Casburn Nov 30 '20 at 21:29
  • Thanks @RandyCasburn. And then how to simulate an F5 in the other tab? I shouldn't simulate an F5 in a single tab and refresh it because in this case i will lose the console as it is a property of the window object. – Mahmood Kiaheyrati Nov 30 '20 at 23:23

0 Answers0