鼠标简单跟随提示二
function id(s){return document.getElementById(s);}/** * 鼠标跟随提示 */function mouseFollow() {var e = e ? e : window.event;var posx = e.clientX;var posy = e.clientY;var followDiv = id("followDiv") ? id("followDiv"): document.createElement("div");followDiv.setAttribute("id","followDiv");var css = "width:100px;height:20px;border:1px solid grey;position:absolute;z-index:10000;left:"+posx+";top:"+posy+";";setCss(followDiv,css);document.body.appendChild(followDiv);}/** * element:需要获取样式的目标元素;name:样式属性 */ function getStyle(element, name) {var computedStyle;try {computedStyle = document.defaultView.getComputedStyle(element, null);} catch (e) {computedStyle = element.currentStyle;}if (name != "float") {return computedStyle[name];} else {return computedStyle["cssFloat"] || computedStyle["styleFloat"];}}/** * element:需要设置样式的目标元素;name:样式属性;value:设置值 */ function setStyle(element, name, value) {if (name != "float") {element.style[name] = value;} else {element.style["cssFloat"] = value;element.style["styleFloat"] = value;}}/** * */function setCss(obj,css){obj.setAttribute("style",css);obj.style.cssText = css;}
?