I was writing OnClick javascript code to open the new web page.
Expectation: I want my to open the new page if that page is not already openend or open the already existing page without reload if that page is already opened.
My code: window.open(url,’dialers’).focus();
This code always reloads the child page if already opened. Please help to achieve my ask.
Advertisement
Answer
You can store the window object into a variable and call the focus()
method multiple times like this:
JavaScript
x
7
1
let newWindow = window.open(url,'dialers')
2
newWindow.focus()
3
doThing()
4
newWindow.focus()
5
doAnotherThing()
6
newWindow.focus()
7