This button page implements "window.open()" to open a new window.
I would like to ask how I can automatically bring the button page to focus if I am browsing another page and the button page is not closed. I don't want to use "window.open" again to bring the button page to focus.
Before, I tried to execute a certain page in the background, and then I wanted to use the "window.location.href" to a page that open a new window of the button page after a period of time, so that the button page becomes the focus of execution, but I failed.
Later I tried a page in the background using "window.location.href" to jump to the button page then the button page automatically become the focus, but failed!
Because I am new for js, trouble a little more detailed, please help me! Thank you very much!

This is marked solved. Can you share the fix?

commented: Oh my gob! I have made a mistake +0

I see the Question Solved? has been removed.

Now if this was my task I'd check out https://www.w3schools.com/jsref/met_win_focus.asp

This method makes a request to bring the current window to the foreground. It may not work as you expect in all browsers, due to different user settings.

But due to browser settings and how this works IRL you can NEVER EXPECT THIS TO WORK everywhere and everytime. Thank those that used this and other schenigans to pop adverts at folk.

commented: This doesn't work with me! Anyway, thanks for your advice! +0

iscjm, I tested this at the w3schools link both in Try It Now and other places and it works fine. HOWEVER due to differences in browsers, browser settings and security suites PLUS pop-up blockers you can NEVER be sure this will work.

In case you wonder why, it's all because the spammers and others overused pop-ups, pop-unders and more so the browsers and the people fought back. I can't guess why you need this as you didn't say but at least you know why it's not something that you can count on and there is NO REASON to fix it since the spammers, advertisers and malware makers would only take advantage of it again.

commented: Because in many browsers, if you call "window.open" directly, it will be blocked, except you call "window.open" with "onclick" in the "button" tag. Be +0
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.