Ok, you got the obligatory 'wrong list' comments.  It is the wrong list, but 
for the sake of public completeness... how about an answer to the question.

You can put it anywhere but a couple of considerations:

1. I believe if you put it AFTER where the JS functions defined in that block 
are called, it may try to call the functions before the functions appear.  So 
close to the top is always good.  I could be wrong on this, but there was some 
kind of condition along those lines and I think it was with JS and positioning.

2. Non JS compliant browsers.  If you put it in the <body>, they're likely to 
ignore the <script> tags and just blatantly display the JS as if it was meant 
for output.  This can be mitigated by using HTML comment blocks around the JS. 
Since they're different than JS comment blocks, it won't interfere with the JS. 
 But putting your <script> in the <head> block should also prevent it from 
being displayed.

3. If you're executing JS in order to output something, you're going to need to 
put it whereever in your HTML you'll need the output.  If you're just defining 
functions to be called later, then you can put it whereever (probably above 
where you're calling the functions.. see #1).

The only things we don't put in the <head> for <script> blocks is a popup 
calendar thing that the old developer installed and our users seem to like.  
Part of it's requirements is a <script> tag that includes some JS and HTML 
where you want the popup calendar to appear.   Could probably be streamlined, 
but works well enough and doesn't look too ugly so why make more work for 
ourselves until we do the full re-design (2035?)

-TG

= = = Original message = = =

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>

TIA, Cor


___________________________________________________________
Sent by ePrompter, the premier email notification software.
Free download at http://www.ePrompter.com.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to