Re: javascript in <head> or in <body> ?
| From: | Tijnema | Date: | Tue, 07 Aug 2007 19:42:53 +0000 |
| Subject: | Re: javascript in <head> or in <body> ? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-260316@lists.php.net to get a copy of this message | ||
On 8/7/07, Richard Heyes <richardh@phpguru.org> wrote:
> 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>
>
> Either really. Both work.
>
> --
> Richard Heyes
Actually, I didn't want to answer this, but you're talking shit here ;)
Javascript needs to be initialised before it can be used.
So, if you have a function bodyload(), and you call it from <body
onload="bodyload();">, you need to place it inside <head>, as it isn't
loaded if you put it in <body>.
Some browsers will still run the javascript code, however it is not recommended.
Tijnema
--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info