关于EventTarget.addEventListener():
https://developer.mozilla.org/zh-CN/docs/Web/API/EventTarget/addEventListener
代码:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
hi
<script type="text/javascript">
function add(e) {
console.log('document.readyState: ', document.readyState)
console.log('trigger: ', e);
}
if (document.addEventListener) {
document.addEventListener('readystatechange', add);
}
else if(document.attachEvent) { // IE
document.attachEvent('onreadystatechange', add);
}
</script>
</body>
</html>
浏览器打开,运行结果:
转载于:https://my.oschina.net/letiantian/blog/775916