- 最后登录:
- 2024-12-3 16:37<
- 注册时间:
- 2012-8-31 12:10
- 阅读权限:
- 200
- UID:
- 1
- 在线时间:
- 1644 小时
|
代码二
- <script type="text/javascript">
- var isIE = /msie/i.test(navigator.userAgent);
- function gID(id){return document.getElementById(id);}
- function ScrollDiv(id,pScrollY){
- var ScrollY = document.documentElement.scrollTop || document.body.scrollTop;
- if (pScrollY ==null) { pScrollY=0; }
- var moveTop = .1 * (ScrollY - pScrollY);
- moveTop = (moveTop > 0) ? Math.ceil(moveTop) : Math.floor(moveTop);
- gID(id).style.top = parseInt(gID(id).style.top) + moveTop + "px";
- pScrollY = pScrollY + moveTop;
- setTimeout("ScrollDiv('"+id+"',"+pScrollY+");",50);
- }
- function addObjEvent(obj,eventName,eventFunc){
- if (obj.attachEvent){
- obj.attachEvent(eventName,eventFunc);
- }else if (obj.addEventListener){ //FF Gecko / W3C
- var eventName2 = eventName.toString().replace(/on(.*)/i,'$1');
- obj.addEventListener(eventName2,eventFunc, false);
- }else{
- obj[eventName] = eventFunc;
- }
- }
- function delObjEvent(obj,eventName,eventFunc){
- if (obj.detachEvent) {
- obj.detachEvent(eventName,eventFunc);
- }else if (obj.removeEventListener){ //FF Gecko / W3C
- var eventName2 = eventName.toString().replace(/on(.*)/i,'$1');
- obj.removeEventListener(eventName2,eventFunc, false);
- }else{
- obj[eventName] = null;
- }
- }
- function MoveDiv(obj,e){
- e = e||window.event;
- var ie6=isIE;
- if (/msie 9/i.test(navigator.userAgent)) {ie6=false;}
-
- if (ie6 && e.button == 1 || !ie6 && e.button == 0) {}else{return false;}
- obj.style.position='absolute';
- obj.ondragstart =function(){return false;}
- var x = e.screenX - obj.offsetLeft;
- var y = e.screenY - obj.offsetTop;
- addObjEvent(document,'onmousemove',moving);
- addObjEvent(document,'onmouseup',endMov);
- e.cancelBubble = true;
-
- if (isIE) {
- obj.setCapture();
- } else {
- window.captureEvents(Event.mousemove);
- }
-
- if (e.preventDefault) {
- e.preventDefault();
- e.stopPropagation();
- }
- e.returnValue = false;
- return false;
-
- function moving(e){
- obj.style.left = (e.screenX - x) + 'px';
- obj.style.top = (e.screenY - y) + 'px';
- return false;
- }
-
-
- function endMov(e){
- delObjEvent(document,'onmousemove',moving);
- delObjEvent(document,'onmouseup',arguments.callee);
- if (isIE) {
- obj.releaseCapture();
- } else {
- window.releaseEvents(Event.mousemove);
- }
- }
- }
- </script>
- <style>
- .KeFuDiv{
- position: absolute;
- height:160px;
- width:118px;
- z-index:9999;
- }
- </style>
- <div id="KeFuDiv" class="KeFuDiv"><a href="https://www.xmspace.net" target="_blank"><img src="/app.png" alt="说明"></a></div>
- <script>
- gID("KeFuDiv").style.top = (document.documentElement.clientHeight - gID("KeFuDiv").offsetHeight)/4 +"px";
- gID("KeFuDiv").style.right = document.documentElement.clientWidth - gID("KeFuDiv").offsetWidth - "10px" +"px";
- ScrollDiv('KeFuDiv');
- </script>
复制代码 |
|