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.

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:closed
  • Created 8 years ago
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
baganacommented, May 21, 2015

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.

0reactions
darkguy2008commented, Sep 3, 2019

Same happened to me when spawning a window today using a js file as main entrypoint.

Fixed it with @bagana’s code. Thanks!

Read more comments on GitHub >

github_iconTop 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 >

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