日期:2014-05-16  浏览次数:20406 次

[求解]window.onload=function(){} 和 <body onLoad="testbody();"> 不能同时应用!
例:
<html>
<head>
<meta   http-equiv= "Content-Type "   content= "text/html;   charset=utf-8 ">
<title> test </title>
<script>
function   testbody(){
alert( "body ");
}
window.onload=function(){
alert( "window ");
}
</script>
</head>

<body   onLoad= "testbody(); ">
</body>
</html>


------解决方案--------------------
<html>
<head>
<meta http-equiv= "Content-Type " content= "text/html; charset=utf-8 ">
<title> test </title>
<script>
function testbody(){
alert( "body ");
}
window.onload=function(){
testbody();
alert( "window ");
}
</script>
</head>

<body onLoad= "testbody(); ">
</body>
</html>
======================
这样可以吗?
:-)
------解决方案--------------------
...
<script>
function testbody(){
alert( "body ");
}
window.onload=function(){
testbody();
alert( "window ");
}
</script>
...
<body>
</body>
------解决方案--------------------
if (window.onload != null) {
var oldOnload = window.onload; //未知的可能已经存在的
window.onload = function (e) {
oldOnload(e);
test(); //现在要调用的
};
} else {
window.onload = cssLoad;
}
------解决方案--------------------
你用attachEvent 来实现你的需求