If I asked you what Window.load and window.onload meant, I'm afraid you would answer me, "This is not the end of the page."
But the answer is not necessarily, depends on how you use. Take a look at the example.
Example 1:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title>Untitled</title>
<script type= "Text/javascript" >
function ShowMessage ()
{
Alert ("true");
}
Window.onload=showmessage ();
</script>
<body>
You can't see me when you see true
</body>
When you see the pop-up box true, you definitely do not see "When you see true, you do not see me", the page has not been loaded after the start of JS has been implemented.
Example 2
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 transitional//en" >
<title>Untitled</title>
<script type= "Text/javascript" >
function ShowMessage ()
{
Alert ("true");
}
Window.onload=function () {showmessage ();}
</script>
<body>
You saw me when you saw true.
</body>
When you see the pop-up box of True, you will also see "You see me when you see true", this is the real page load to trigger.
PS: Recommend the use of anonymous functions such as the OnLoad event, i.e. window.onload=function () {showmessage ();} This form.