I am working on a webpage named 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>
In addition, I also have another page called 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>
The goal is to trigger an 'ank' alert when the welcome.html file is being loaded through ajax as there is an alert function written in the body's onload attribute of welcome.html