Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I refresh a tab from another using Javascript

Tags:

javascript

I'm looking to achieve something like Wordpress does when you create a new post. It allows you to preview your post by opening a new tab. If, after that, you edit the post and preview it again, rather than opening another tab, it refreshes the previously opened tab (provided it is still open).

From some research it seems I can open a new window and give it a name to identify it, like this:

window.open(url,"foobar");

But, how can I later refresh this tab? location.reload() does not seem to take a name as an argument.

like image 876
xbonez Avatar asked May 19 '12 03:05

xbonez


People also ask

How do you refresh using JavaScript?

You can use the location. reload() JavaScript method to reload the current URL. This method functions similarly to the browser's Refresh button. The reload() method is the main method responsible for page reloading.

How do I refresh a page on another page?

The JavaScript reload() method is used to reload the current document in JavaScript/jQuery. The reload() method can reload the current resource . The method also has other perks, such as helping you get the URL address of the current page, redirect the browser to another page, refresh page etc.

How do you refresh tabs in HTML?

Window location.reload() The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.

Can refresh the webpage in JavaScript by using?

Location. reload() method is used to refresh the webpage in javascript.


1 Answers

If I remember correctly this is the way to do it:

var win = window.open(url, "foobar");
win.location.reload();
like image 61
Aadit M Shah Avatar answered Sep 19 '22 12:09

Aadit M Shah