Home > Article > Web Front-end > Page loading techniques for window.onload_javascript techniques
After testing the two pieces of code separately, it was found that window.onload without brackets showed the correct effect after the page was loaded. I think window.onload is also equivalent to a trigger event. If the function has parentheses, the function will be executed directly first, and then the body will be loaded. Without parentheses, it is equivalent to assigning a function as a variable to window.onload and not loading it immediately.
Code 1: