간단한 마우스 따르기 알림 2

1567 단어 힌트
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;
}

좋은 웹페이지 즐겨찾기