日期:2014-05-16 浏览次数:20366 次
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function Messager(msg) {
this.msg = msg;
}
Messager.prototype.alert = function() {
alert(this.msg);
var fn = null;
if (this.alert.bind) {
fn = this.alert.bind(this);
} else {
var targetThis = this;
fn = function() {
targetThis.alert.apply(targetThis, arguments);
};
}
setTimeout(fn, 1000);
};
window.onload = function() {
new Messager("Hello").alert();
}
</script>
</head>
<body>
</body>
</html>
------解决方案--------------------
改一行代码:
setTimeout("window.onload()",1000);