如何使用javascript在计算机屏幕上移动窗口的位置? [英] How do I move a window's position on the computer screen with javascript?

查看:120
本文介绍了如何使用javascript在计算机屏幕上移动窗口的位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我记得看过一个谷歌地图mashup /音乐视频,它在屏幕上创建,调整大小和移动窗口。使用了哪些javascript方法?

I remember seeing a google maps mashup / music video that created, resized, and moved windows on the screen. What javascript methods are used to do this?

推荐答案

我不知道这是多么可靠,但要相对移动窗口到目前的位置你可以这样做:

I don't know how reliable this is, but to move the window relative to it's current position you can do this:

window.moveBy(250, 250); //moves 250px to the left and 250px down

http://www.w3schools.com/jsref/met_win_moveby.asp

要将窗口移动到屏幕的某个部分:

To move the window to a certain part of the screen:

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提供:

Courtesy of @Dan Herbert:


应该注意 window.moveTo(0, 0)将移动到主屏幕左上角的
。对于拥有多个
监视器的人,您还可以将负坐标发送到另一个
监视器上的位置。您可以使用
screen.availLeft 来检查第二台显示器。如果它是负数,你可以将一个远远超过
的窗口移动到第二台显示器上。

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 with screen.availLeft. If it's negative, you can move a window that far onto the second monitor.

这篇关于如何使用javascript在计算机屏幕上移动窗口的位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆