Home  >  Article  >  Web Front-end  >  Some experience on using the onload event of js_Basic knowledge

Some experience on using the onload event of js_Basic knowledge

WBOY
WBOYOriginal
2016-05-16 17:25:501046browse

If I ask you what window.load and window.onload mean respectively, I'm afraid you will answer me: "Isn't this executed after the page is loaded?"
But the answer is not necessarily, it depends on how you use it. Take a look at the example
Example 1:

Copy the code The code is as follows:

< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">


Untitled



You can’t see me when you see true



When you see the true pop-up box, you definitely don’t see “You can’t see me when you see true”, which means that the js execution has started before the page is loaded. . " -//W3C//DTD HTML 4.0 Transitional//EN">

Untitled


You see me when you see true




When you see the true pop-up box, you will also see "When you see true, you see me." This is only triggered after the real page is loaded.
PS: It is recommended to use anonymous functions like onload events, that is, window.onload=function(){ShowMessage();}.
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn