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.
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.
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.
Window location.reload() The reload() method reloads the current document. The reload() method does the same as the reload button in your browser.
Location. reload() method is used to refresh the webpage in javascript.
If I remember correctly this is the way to do it:
var win = window.open(url, "foobar");
win.location.reload();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With