First is the code listing for the Addloadevent function:
function Addloadevent (func)
{
var oldonload=window.onload;
if (typeof window.onload!= ' function ')
{
Window.onload=func
}
else
{
window.onload=function ()
{
oldonload ();
Func ();}}
Understood is:
1. Deposit the value of the existing Window.onload event handler function into the variable oldonload;
2. If you have not yet bound any function on this handler function, add the new function to it as usual;
3. If you have already bound some functions on this handler, append the new function to the end of the existing instruction.
This function is very practical, especially when the code becomes more and more complex, no matter how many functions you intend to perform on the page, just write one more statement to get it done.
The above JS addloadevent function is a small series to share all the content, hope to give you a reference, but also hope that we support the cloud habitat community.