Forum Moderators: open
Some pages require javascript... do it create some thing like:
<html>
<head>
...
</head>
<body>
<script>...</script>
...
</body>
</html>
I can't really place the script in the <head> because I should create a specific page detection in the header.php file and it would be conplicated and not really clean.
Now I know this method work, but, I'm trying to code in XHTML STRIC... so I wanted to know if it was "legal" to put java script inside the <body> ...
:-\
Your best bet is to stuff it all into an external .js file (simple text saved with a .js extension) and add...
<script type="text/javascript" src="YOURFILE.js"></script>
...to the <head>.
This could be included in the head of pages that don't need the JS and will not affect anything until and unless the script functions are called.
As to your question about XHTML strictness, I don't know, but I guess not. It certainly is easier to use an external link.