user5858 user5858 - 6 months ago 11
Javascript Question

Open a url in new and same tab again and again

I'm unable to find the answer.

How can I use window.open to open a link in a new tab?

Repeated calling should reload that same tab and not open a new one.

I've a button when clicked should load an url. Repeated click should reload in the same tab/window.

Answer

You need to pass a name as the second parameter to window.open

As long as the tab with that name has not been closed, it will be reused.