首页 > Windows开发 > 详细

Window Position

时间:2015-05-19 18:25:27      阅读:315      评论:0      收藏:0      [点我收藏+]

  IE, Safari, Opera, and Chrome all provide screenLeft and screenTop properties that indicate the window‘s location in relation to the left and top of the screen, respectively. Firefox provides this functionality through the screenX and screenY, which are also supported in Safari and Chrome. Opera supported screenX and screenY, but you should avoid using them in Opera, because they don‘t correspond to screenLeft and screenTop. The following code determines the left and top positions of the window across browsers:

1 var leftPos = (typeof window.screenLeft == "number")? window.screenLeft : window.screenX;
2 var topPos = (typeof window.screenTop == "number")? window.screenTop : window.screenY;

  This example uses the ternary operator to determine if the screenLeft and screenTop properties exist. If they do(which is the case in IE, Safari, Opera, and Chrome), they are used. If they don‘t exist(as in Firefox), screenX and screenY are used.

 

Window Position

原文:http://www.cnblogs.com/linxd/p/4515026.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!