Position javascript window.open centered on secondary screen?

馋奶兔 提交于 2019-12-12 06:06:42

问题


I have this code from an example:

<script type="text/javascript">
function open_and_move2(){

win3=window.open("page.htm","","width=600,height=500")
win3.moveTo(screen.width/2-300,screen.height/2-250)
}
</script>

It works just fine with the exception that, if the browser window is located at a secondary screen, the javscript window pops up on the main screen.

Seems like the calculated offsets would be correct for the secondary screen, but the offsets are executed on an absolute scope.

I would like to have a window open on click positioned in the middle of the current screen or current window.

How can I do that?

The reason is that I am implementing single sign on for a website and this should be used for a comments plugin.

来源:https://stackoverflow.com/questions/6911138/position-javascript-window-open-centered-on-secondary-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!