Re: javascript in <head> or in <body> ?
| From: | Robert Cummings | Date: | Tue, 07 Aug 2007 19:28:03 +0000 |
| Subject: | Re: javascript in <head> or in <body> ? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260308@lists.php.net to get a copy of this message | ||
On Tue, 2007-08-07 at 21:19 +0100, C.R.Vegelin wrote:
> Are there any rules when to include javascript in <head> or in <body> ?
> For example,
> <script type="text/javascript">
> function reload(form)
> { var val=form.Chapter.options[form.Chapter.options.selectedIndex].value;
> self.location='QueryForm.php?Chapter=' + val ;
> }
> </script>
In <head> - whenever possible
In <body> - whenever else
It's not incorrect to have JS in the body, but it sure makes it more
difficult to see what's happening.
Cheers,
Rob.
--
...........................................................
SwarmBuy.com - http://www.swarmbuy.com
Leveraging the buying power of the masses!
...........................................................