梦想 就像鸡蛋
要么孵化 要么臭掉
要么孵化 要么臭掉
可移动层的实现示例
Made In Zeal 转载请保留原始链接:http://www.zeali.net/entry/12
本文提供了一个通过javascript+dhtml脚本实现在IE浏览器里面显示的可以被鼠标拖动的层。这个层能够自动滚动或者被关闭,就像我的Z-Tips一样:)
This Entry was Last Modified on 2007-05-24 16:35
发贴统计

我的地盘
// begin fly bar
var bIsCatchFlyBar = false;
var cur_divX = 0;
var cur_divY = 0;
function catchFlyBar(event)
{
bIsCatchFlyBar = true;
var cursorX = event.clientX;
var cursorY = event.clientY;
cur_divX = cursorX - document.getElementById("showdiv").style.left.split("p")[0];
cur_divY = cursorY - document.getElementById("showdiv").style.top.split("p")[0];
if(isIE)
{
movediv.setCapture();
document.onmousemove = moveFlyBar;
}
else
{
window.captureEvents(Event.MOUSEMOVE);
window.onmousemove = moveFlyBar(event);
}
}
function releaseFlyBar(event){
bIsCatchFlyBar = false;
if(isIE)
{
movediv.releaseCapture();
document.onmousemove = null;
}
else
{
window.releaseEvents(Event.MOUSEMOVE);
window.onmousemove = null;
}
}
function moveFlyBar(evt)
{
if(bIsCatchFlyBar)
{
if(isIE)
{
document.getElementById("showdiv").style.left = (event.clientX - cur_divX) + "px";
document.getElementById("showdiv").style.top = (event.clientY - cur_divY) + "px";
}
else
{
document.getElementById("showdiv").style.left = (evt.clientX - cur_divX) + "px";
document.getElementById("showdiv").style.top = (evt.clientY - cur_divY) + "px";
}
}
}