I am designing a new bookmarklet and I am testing it on Opera.
This is my code:
javascript:(function(){var a=window.open('http://www.google.com','Ok','left='+((window.screenLeft||window.screenX)+10)+',top='+((window.screenY||window.screenTop)+0)+',height=200px,width=400px,resizable=1,alwaysRaised=1,location=1,links=0,scrollbars=0,toolbar=0');window.setTimeout(function(){a.focus()},250)})();
The problem is that the new window doesn’t appear on the top but at about 200px from the top ( in other browsers like internet explorer, firefox and chrome it works well ).
So, Why this window doesn’t appear on the top in Opera ?
Your problem comes from the fact that in Opera, both window.screenY and window.screenTop are defined, and screenY seems to always equal 0 which is a falsy value in JavaScript, so
would always return window.screenTop in Opera while you actually need the first value.
The proper way of checking is:
Here is your complete code, I also updated the check for screenLeft / screenX:
Good luck.