温馨提示:代码在线浏览功能只能做为源码浏览参考,不能展示项目的全部,如果想更进一步了解该代码请下载:漂亮许愿墙前台程序源码
当前文件路径:AspNetXuYuanQiang/js/genmove.js

1/////////////////////////////////////////////////////////////////////// 2
// This script was designed by Erik Arvidsson for WebFX // 3
// // 4
// For more info and examples see: http://webfx.eae.net // 5
// or send mail to erik@eae.net // 6
// // 7
// Feel free to use this code as lomg as this disclaimer is // 8
// intact. // 9
/////////////////////////////////////////////////////////////////////// 10
11
var checkZIndex = true; 12
13
var dragobject = null; 14
var tx; 15
var ty; 16
17
var ie5 = document.all != null && document.getElementsByTagName != null; 18
19
function getReal(el) { 20
temp = el; 21
22
while ((temp != null) && (temp.tagName != "BODY")) { 23
if ((temp.className == "moveme") || (temp.className == "handle")){ 24
el = temp; 25
return el; 26
} 27
temp = temp.parentElement; 28
} 29
return el; 30
} 31
32
33
function moveme_onmousedown() { 34
el = getReal(window.event.srcElement) 35
36
if (el.className == "moveme" || el.className == "handle") { 37
if (el.className == "handle") { 38
tmp = el.getAttribute("handlefor"); 39
if (tmp == null) { 40
dragobject = null; 41
return; 42
} 43
else 44
dragobject = eval(tmp); 45
} 46
else 47
dragobject = el; 48
49
if (checkZIndex) makeOnTop(dragobject); 50
51
ty = window.event.clientY - getTopPos(dragobject); 52
tx = window.event.clientX - getLeftPos(dragobject); 53
54
window.event.returnValue = false; 55
window.event.cancelBubble = true; 56
} 57
else { 58
dragobject = null; 59
} 60
} 61
62
function moveme_onmouseup() { 63
if(dragobject) { 64
dragobject = null; 65
} 66
} 67
68
function moveme_onmousemove() { 69
if (dragobject) { 70
if (window.event.clientX >= 0 && window.event.clientY >= 0) { 71
dragobject.style.left = window.event.clientX - tx; 72
dragobject.style.top = window.event.clientY - ty; 73
} 74
window.event.returnValue = false; 75
window.event.cancelBubble = true; 76
} 77
} 78
79
function getLeftPos(el) { 80
if (ie5) { 81
if (el.currentStyle.left == "auto") 82
return 0; 83
else 84
return parseInt(el.currentStyle.left); 85
} 86
else { 87
return el.style.pixelLeft; 88
} 89
} 90
91
function getTopPos(el) { 92
if (ie5) { 93
if (el.currentStyle.top == "auto") 94
return 0; 95
else 96
return parseInt(el.currentStyle.top); 97
} 98
else { 99
return el.style.pixelTop; 100
} 101
} 102
103
function makeOnTop(el) { 104
var daiz; 105
var max = 0; 106
var da = document.all; 107
108
for (var i=0; i<da.length; i++) { 109
daiz = da[i].style.zIndex; 110
if (daiz != "" && daiz > max) 111
max = daiz; 112
} 113
114
el.style.zIndex = max + 1; 115
} 116
117
if (document.all) { //This only works in IE4 or better 118
document.onmousedown = moveme_onmousedown; 119
document.onmouseup = moveme_onmouseup; 120
document.onmousemove = moveme_onmousemove; 121
} 122
123
document.write("<style>"); 124
document.write(".moveme {cursor: move;}"); 125
document.write(".handle {cursor: move;}"); 126
document.write("</style>");




temp 
}
}