Kathrine22
04-24-2007, 03:25 AM
What is the difference between calling a function in HEAD and calling a function in BODY?:confused:
|
Click to See Complete Forum and Search --> : Calling functions Kathrine22 04-24-2007, 03:25 AM What is the difference between calling a function in HEAD and calling a function in BODY?:confused: Typhoon101 04-24-2007, 03:34 AM When an html page loads, it reads your code from top to bottom. Therefore any script written in the head is performed before the actual site content is written to the page. Although you can write functions in the body, it is good practice to include all of your scripts either in an external file or within the head. It makes things neat. Within the body you should only really use JavaScript to call functions that were previously written in the head. Kathrine22 04-24-2007, 03:43 AM If I want to run the code of a function whan the document is loaded where should I call it? Typhoon101 04-24-2007, 03:49 AM You would still write it in the head. However, you would need to insert it in an onload function. For example window.onload = function(){ your code here } webdeveloper.com
Copyright Internet.com Inc., All Rights Reserved. |