我正在尝试创建一个300px乘300 px的div框,它随鼠标移动。唯一的事情是当访问者点击div它消失。任何帮助将不胜感激。
if((document.getElementById)&& window.addEventListener || window.attachEvent){(function(){var hairCol =" #ff0000&#34 ;;
var d = document; var my = -10; var mx = -10; var r; var
vert ="";
var idx = document.getElementsByTagName('div').length; var thehairs = "<div id='theiframe' scrolling='no'
风格=&#39;位置:绝对的;宽度:53px;高度:23像素;溢出:隐藏;边界:0;不透明度:&#34; + opacity +&#34 ;; filter:alpha(opacity =&#34; + opacity * 100+&#34;);&#39;&gt; dsdsds&#34 ;;文件撰写(thehairs); var like = 的document.getElementById(&#34; theiframe&#34); document.getElementsByTagName(&#39;主体&#39;)[0] .appendChild(等);
var pix = "px"; var domWw = (typeof window.innerWidth ==
&#34;数&#34); var domSy =(typeof window.pageYOffset ==&#34; number&#34;);
if (domWw) r = window; else{ if (d.documentElement &&
typeof d.documentElement.clientWidth ==&#34; number&#34; &安培;&安培; d.documentElement.clientWidth!= 0) r = d.documentElement;其他{ if(d.body&amp;&amp; typeof d.body.clientWidth ==&#34; number&#34;) r = d.body; }}
if(time != 0){ setTimeout(function(){ document.getElementsByTagName('body')[0].removeChild(like); if (window.addEventListener){ document.removeEventListener("mousemove",mouse,false); } else if (window.attachEvent){ document.detachEvent("onmousemove",mouse); } }, time); } function scrl(yx){ var y,x; if (domSy){ y = r.pageYOffset; x = r.pageXOffset; } else{ y = r.scrollTop; x = r.scrollLeft; } return (yx == 0) ? y:x; } function mouse(e){ var msy = (domSy)?window.pageYOffset:0; if
(!E) e = window.event; if(typeof e.pageY ==&#39; number&#39;){ my = e.pageY - 5 - msy; mx = e.pageX - 4; } else { my = e.clientY - 6 - msy; mx = e.clientX - 6; } vert.top = my + scrl(0)+ pix; vert.left = mx + pix; }
function ani(){ vert.top = my + scrl(0) + pix; setTimeout(ani,
300); }
function init(){ vert =
的document.getElementById(&#34; theiframe&#34)。样式; ANI();如果 (window.addEventListener){ window.addEventListener(&#34;负载&#34;在初始化,FALSE); document.addEventListener(&#34;鼠标移动&#34;,小鼠,假);否则如果 (window.attachEvent){window.attachEvent(&#34; onload&#34;,init); document.attachEvent(&#34;的OnMouseMove&#34;,小鼠); }
})();
} //结束。