我有一个页面 index.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=iso-8859-1" />
<title>Lufia</title>
<script language="javascript" type="text/javascript">
function ajax()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{if (xmlhttp.readyState==4 && xmlhttp.status==200)
document.getElementById('mydiv').innerHTML=xmlhttp.responseText;
}
xmlhttp.open("GET",'welcome.html',true);
xmlhttp.send();
}
</script></head>
<body>
<button onclick="ajax();"></button><div id="mydiv"></div></body>
</html>
还有一个叫做welcome.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=iso-8859-1" />
<title>Lufia</title>
<body onload="alert('ank');">welcome
</body>
</html>
我希望它在welcome.html通过ajax加载时提醒ank,因为警报功能写在welcome.html的body onload属性上