我记得看过一个谷歌地图混搭/音乐视频,它可以在屏幕上创建、调整大小和移动窗口。使用哪些 javascript 方法来执行此操作?
最佳答案
我不知道这有多可靠,但是要相对于当前位置移动窗口,您可以这样做:
window.moveBy(250, 250); //moves 250px to the left and 250px down
http://www.w3schools.com/jsref/met_win_moveby.asp
将窗口移动到屏幕的某个部分:
window.moveTo(0, 0); //moves to the top left corner of the screen (primary)
http://www.w3schools.com/jsref/met_win_moveto.asp
由@Dan Herbert 提供:
It should probably be noted that
window.moveTo(0,0)
will move to the top left corner of the primary screen. For people with multiple monitors you can also send negative coordinates to position on another monitor. You can check for a second monitor to move to withscreen.availLeft
. If it's negative, you can move a window that far onto the second monitor.
关于javascript - 如何使用 javascript 移动窗口在计算机屏幕上的位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7841849/