当前位置: 技术问答>java相关
如何取得浮动层的坐标?(层在网页中可以随便拖动)
来源: 互联网 发布时间:2015-10-31
本文导语: 最近因为要做套打,所以要做一些可以由用户自行拖动位置的层,但我要取到 这些层的坐标才能将它做成模版,请高手指点一下如何取到这些层的坐标? 谢谢!! | 浮动层 id=LayerTree ...
最近因为要做套打,所以要做一些可以由用户自行拖动位置的层,但我要取到
这些层的坐标才能将它做成模版,请高手指点一下如何取到这些层的坐标?
谢谢!!
这些层的坐标才能将它做成模版,请高手指点一下如何取到这些层的坐标?
谢谢!!
|
浮动层 id=LayerTree
self.onError = null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
function heartBeat()
{
if(IE) {
diffY = document.body.scrollTop; diffX = document.body.scrollLeft;
}
if(NS) {
diffY = self.pageYOffset; diffX = self.pageXOffset;
}
if(diffY != lastScrollY) {
percent = .1 * (diffY - lastScrollY);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.LayerTree.style.pixelTop += percent;
if(NS) document.LayerTree.top += percent;
lastScrollY = lastScrollY + percent;
}
if(diffX != lastScrollX) {
percent = .1 * (diffX - lastScrollX);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.LayerTree.style.pixelLeft += percent;
if(NS) document.LayerTree.left += percent;
lastScrollX = lastScrollX + percent;
}
}
function checkFocus(x,y)
{
stalkerx = document.LayerTree.pageX;
stalkery = document.LayerTree.pageY;
stalkerwidth = document.LayerTree.clip.width;
stalkerheight = document.LayerTree.clip.height;
if( (x > stalkerx && x stalkery && y
self.onError = null;
currentX = currentY = 0;
whichIt = null;
lastScrollX = 0; lastScrollY = 0;
NS = (document.layers) ? 1 : 0;
IE = (document.all) ? 1: 0;
function heartBeat()
{
if(IE) {
diffY = document.body.scrollTop; diffX = document.body.scrollLeft;
}
if(NS) {
diffY = self.pageYOffset; diffX = self.pageXOffset;
}
if(diffY != lastScrollY) {
percent = .1 * (diffY - lastScrollY);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.LayerTree.style.pixelTop += percent;
if(NS) document.LayerTree.top += percent;
lastScrollY = lastScrollY + percent;
}
if(diffX != lastScrollX) {
percent = .1 * (diffX - lastScrollX);
if(percent > 0) percent = Math.ceil(percent);
else percent = Math.floor(percent);
if(IE) document.all.LayerTree.style.pixelLeft += percent;
if(NS) document.LayerTree.left += percent;
lastScrollX = lastScrollX + percent;
}
}
function checkFocus(x,y)
{
stalkerx = document.LayerTree.pageX;
stalkery = document.LayerTree.pageY;
stalkerwidth = document.LayerTree.clip.width;
stalkerheight = document.LayerTree.clip.height;
if( (x > stalkerx && x stalkery && y