Window.focus() not taking focus
See original GitHub issue"window": {
"fullscreen": false,
"resizable": true,
"show": false,
"always-on-top": true,
"frame": false,
"title": "Verystar POS",
"focus": true,
"height": 600,
"min_height": 500,
"visible": true,
"as_desktop": true,
"width": 800,
"position": "center",
"min_width": 800,
"exe_icon": "logo.png",
"show_in_taskbar": true,
"mac_icon": "logo.icns",
"transparent": false,
"toolbar": false,
"icon": "logo.png"
},
function showWindow(){
win.show();
win.focus(); <--- not working
}
version nwjs 0.12.1, win32
A similar problem:
focus() works on ‘loaded’ but fails on ‘restore’ in recent versions
https://github.com/nwjs/nw.js/issues/3042
<bountysource-plugin>
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource. </bountysource-plugin>
Issue Analytics
- State:
- Created 8 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
window.focus() not working in Google Chrome
I have a client-side class for managing browser windows. When I first create a window the window comes into focus, but subsequent attempts...
Read more >window.focus from child window does not put focus back ...
1. Launch a new window using window.open with some window name say 'Child'. ... window.opener.focus(). 3. Parent does not get focus. ... child...
Read more >window.focus stopped working
Now I have upgraded to Chrome 64, this no longer works. I can see (log messages, breakpoint) the call to focus() happening in...
Read more >Javascript Window Blur() and Window Focus() Method
Javascript Window Blur() method is used to remove focus from the current window. i.e, It sends the new open Window to the background....
Read more >Window: focus event - Web APIs | MDN
The opposite of focus is blur . This event is not cancelable and does not bubble. Syntax. Use the event name in methods...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I don’t know why, but, for me:
this.show(); this.focus(); // does not work this.minimize(); this.restore(); this.show(); // does not work this.minimize(); this.restore(); this.show(); this.focus(); // does not work this.show(); this.minimize(); this.restore(); // does not work this.show(); this.minimize(); this.restore(); this.focus(); // does not work this.minimize(); this.restore(); this.show(); this.minimize(); this.restore(); this.focus(); // WORKS! this.minimize(); this.restore(); this.show(); this.minimize(); this.restore(); // WORKS!
I’m on Windows 7 64bit, nw.js 0.12.1.
Same happened to me when spawning a window today using a js file as main entrypoint.
Fixed it with @bagana’s code. Thanks!