driz Posted May 6, 2009 Share Posted May 6, 2009 Hi I have written this code" function createHTML5Elements() { document.createElement("article"); document.createElement("nav"); document.createElement("section"); document.createElement("header"); document.createElement("hgroup"); document.createElement("aside"); document.createElement("footer");}createHTML5Elements(); I'm quite new to working with JS Functions, but will that function be loaded by simply saying e.g. function_name();OR do I have to add it to the body onload???Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted May 6, 2009 Share Posted May 6, 2009 It will run as soon as you execute it. The question would be do you want it to run after the page loads or before. Link to comment Share on other sites More sharing options...
driz Posted May 6, 2009 Author Share Posted May 6, 2009 so that last line that I added does execute the code?could you post some examples of how i could run the code before and after, so i can see how its done for learning purposes. thanks. Link to comment Share on other sites More sharing options...
jesh Posted May 6, 2009 Share Posted May 6, 2009 <html><head><script type="text/javascript">function saySomething(text){ alert(text);}saySomething("The page hasn't loaded yet...");window.onload = function() { saySomething("Here we are, the page has loaded..."); }</script></head><body><div>This is in the body.</div></body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.