For example:
Copy codeThe Code is as follows:
<Input id = "btnPost" type = "button" value = "button"/>
When parsing, the browser first loads the input tag and then the img tag.
If you want to determine whether the img tag is fully loaded, you can add a script before and after the img tag, for example
Code
Copy codeThe Code is as follows:
<Div id = "loading"> </div>
<Input id = "btnPost" type = "button" value = "button"/>
<Script type = "text/javascript">
Var msg = document. getElementById ("imga ");
If (msg = null ){
Document. getElementById ("loading"). innerHTML = "generating image control..."; // the setTimeout function is not used here.
}
</Script>
<Script> document. getElementById ("loading"). innerHTML = ""; </script>
Pay attention to the js Code before and after the img label. The above js Code first obtains the img object and then determines whether the object is empty. If it is empty, the loading is not completed, the system prompts you to "generate an image control". After loading, the system hides the information.
The above method applies to all controls or labels, but for controls or labels with onload events (this event is triggered after the corresponding controls or labels are loaded ), we can encapsulate the code behind img into a function for onload to call, as shown below:
Code
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Function loadedImg () {document. getElementById ("loading"). innerHTML = "";}
</Script>
</Head>
<Body>
<Input id = "autocomplete"/>
<Div id = "loading"> </div>
<Input id = "btnPost" type = "button" value = "button"/>
<Script type = "text/javascript">
Var msg = document. getElementById ("imga ");
If (msg = null ){
Document. getElementById ("loading"). innerHTML = "picture control..."; // the setTimeout function is not used here.
}
</Script>
</Body>
From the code above, we can see that the code behind the img tag has been encapsulated into the loadedimg method and called by img onload.
Which controls or labels have onload events? I checked it on the internet as follows (I don't know if it's all complete ):
<Body>, <frame>, <frameset>, <iframe>, , <link>, <script>
There are so many problems.