I’m trying to get the window.focus() function to work with no luck.
var myWindow = window.open('','zzz','width=600,height=700');
myWindow.document.write('test');
myWindow.focus();
If you click run after the jsfiddle page loads then the new window should get back focus. What am I doing wrong?
It “works” for me in FF 15. Users can disable the ability of scripts to open and focus windows, check your settings. Oh, and the pop–up should get focus by default, so you shouldn’t have to call
myWindow.focus().Some minor points that probably having nothing to do with the issue but you may want to fix:
document.write('<title></title><div></div>, a DOCTYPE is highly recommended toodocument.close()