Jump to content

A Little Mistake


just2comment

Recommended Posts

Hi, I do not know if this is the right place to report this, but anyway...In http://www.w3schools.com/js/js_whereto.aspthe text"JavaScripts in the body section will be executed WHILE the page loads.JavaScripts in the head section will be executed when CALLED."is not completely right, more specifically1) Javascript in the head section is always executed if it is not in a function,as in <html> <head> <script type="text/javascript"> document.write("Hello World!"); </script> </head> <body> </body></html>2) JavaScript in the body section will not be executed if it is in a function which is not called.

Link to comment
Share on other sites

In fact, scripts behave the same whether they're in the head or the body. What they're saying is incorrect, but it is a recommendation to keep the functions in the head, and put scripts in the body if they need to execute right after a certain element has loaded.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...