AddEvent
addEvent.html 동적으로 event 추가 하는 처리 하기
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> addEvent Sample </title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
<!--
function addEvent(object, type, handler) {
if (object.addEventListener) {
object.addEventListener(type, handler, false);
} else if (object.attachEvent) {
object.attachEvent("on"+type,handler);
} else {
object["on"+type] = handler;
}
}
window.onload = function () {
var spin = document.createElement('img');
spin.id = 'loadingImage';
spin.src = "http://resource.tattersite.com/findingNemo/thumbnail/1/1047883812.w190-h210.resampled.jpg";
addEvent(spin,'click',function() { self.close() });
document.getElementById("bodyId").appendChild(spin);
}
//-->
</script>
</head>
<body id="bodyId">
</body>
</html>
Comments (0)