js body onload事件的处理
代码如下:<!DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//EN""http://www.w3.org/TR/xh...
代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
body.onload = function ()
{
alert("1");
}
</script>
</head>
<body >
</body>
</html>
问题:为什么没有弹出对话框? 展开
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" language="javascript">
body.onload = function ()
{
alert("1");
}
</script>
</head>
<body >
</body>
</html>
问题:为什么没有弹出对话框? 展开
1个回答
展开全部
window.onload = function(){
alert('window load');
}
document.body.onload = function(){
alert('body load');
}
追问
你是来灌水的吗?!
追答
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>test</title>
<script>
window.onload = function ()
{
alert("window onload");
}
</script>
</head>
<body>
</body>
<script>
// body加载后,才能执行body的onload方法
document.body.onload = function ()
{
alert("body onload");
}
</script>
</html>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询