question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Focusing a parent window

See original GitHub issue

I’ve got one window that opens another window. I would like to then, have a function on the new window on a click event that re-focuses the parent window. Here are some things that I’ve tried:

parent.window.opener.focus()
parent.window.focus();
window.opener.focus();
window.blur();
var newWindow = window.open('','_parentName');newWindow.focus();
parent.win.focus();

According to the old window docs, window.opener.focus() should work, according to the new window docs, win.focus() should work. So I would think parent.win.focus() should work. But it doesn’t. Anyone have a work around? http://docs.nwjs.io/en/latest/References/Window/#winfocus

Edit: on an old version of webkit (0.12.2 I believe) this works: window.open('', '_parentWindowName'); however in 0.13 this does not work anymore.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
MehmetKursatcommented, Sep 9, 2016

focusParentSample.zip

Here’s my implementation, tested with nwjs v0.17.1

0reactions
joshterrillcommented, Sep 9, 2016

When I try the implementation on my code, I get VM2139:1 Uncaught TypeError: Cannot set property 'parentWin' of undefined(…). @RohitSharma27 I don’t understand what you mean by a click. I am not doing anything to click the newly opened window. I’m trying to focus the parent window in an onclick= attribute.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to return focus to the parent window using javascript?
How to return focus to the parent window using javascript? ; head> ; script type="text/javascript"> ; function openWin() { myWindow=window.open('', ...
Read more >
how to keep parent window in focus ? - MSDN - Microsoft
I am doing a window.open to open "page2" . the problem that page2 takes focus and I have to click on first page...
Read more >
How to focus Portal(main or parent) window after on click ...
Hi, Once I logged into end user portal, I am opening a popup window using openurlinwindow on click action. Once popup is opened...
Read more >
child browser window opened via js cannot focus on parent ...
Hey guys, I run into same bug. I can't bring focus on parent window from child. OS: MacOS 10.12.6 (16G1036) Firefox: 57.0.1 (64-bit)...
Read more >
wxChildFocusEvent Class Reference - wxWidgets
A child focus event is sent to a (parent-)window when one of its child windows gains focus, so that the window could restore...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found