When I’m trying to run the following code in IE:-
<html>
<head>
<script language="javascript">
window.onload=function(){
alert("Window.onload is working");
}
</script>
</head>
<body onload="alert('body.onload is working')">
</body>
</html>
It seems that the body.onload overrides window.onload. I want both of them because I have a page and When I press a button, I get a second file and put it inside a div in the first page. So, I need to use window.onload in the first page and when I get the second one, I use body.onload of the second one.
I don’t have this problem in FF,Opera,Chrome and Safari.
I hope my problem is clear. Thanks for any help.
Why not put a JavaScript command at the end of the content that’s being subsequently loaded into the
div? Hence, when the content is loaded the last line is a JavaScript triggering the call to your function. That’s pretty much the simple way of making sure that: (1) content is loaded and (2) you create this function with full cross-browser efficiency.