Reputation: 401
I have this generic javascript function to open a window:
function OpenWindow(url,windowname,wide,high)
{
spop=window.open(url,windowname,"width="+wide+",height="+high+",scrollbars=1,resizable=1,statusbar=1,menubar=0");
spop.moveTo(Math.round((screen.availWidth-wide)/2),Math.round((screen.availHeight-high)/2));
spop.focus();
}
After opening it, I move it to the middle of the screen. The problem is that Chrome is currently hiding the opened window (it works fine in Explorer and Firefox). It opens it, moves it, but then the windows stays minimized and unaccesible.
The funny thing is that if I double click on the link that calls the function, then the window appears where it should, only that its size and height are incorrect (it's very small, and I hav to resize it). Even funnier, is that it used to work in Chrome, but stopped working a couple of months ago.
Apaprently the problem is not the focus() call (I have found people having issues with it). If I remove the moveTo(), the window appears (but not centered).
Any ideas? Thanks!
Upvotes: 1
Views: 461
Reputation: 3552
It turns out this is a known bug in the current version of Chrome:
http://code.google.com/p/chromium/issues/detail?id=115585
It seems the fix is to delay any calls to resizeTo or moveTo after calling open, for example:
setTimeout(function(){
spop.moveTo(
Math.round((screen.availWidth - wide) / 2),
Math.round((screen.availHeight - high) / 2)
);
spop.focus();
},100);
Not the most elegant solution, but it should suffice until the bug is fixed.
Upvotes: 1