Click to See Complete Forum and Search --> : Where to place script code? Before, after body tag?


SAFX
07-23-2003, 09:04 AM
I've been experiencing intermittent problems with my web-based application, which uses simple Javascript. Currently, all my <script></script> code is placed at the bottom of my web page, after the </html> tag. Every so often, if I click on a button or link that uses the script code, I get an error "Object excepted". The error never seems to make sense because I haven't altered the script code in weeks. I took a closer look at the source of the page and I noticed that the source ended just before my script code! It seemed as though the browser just stopped parsing and did not read the page further. A very strange problem because, like I said, it doesn't always occur.

Anyway, where is the best place for script code on a page? Inside the html tags? Before the body? After, ...?

Thanks,

SAFX

Charles
07-23-2003, 09:54 AM
Your script is a part of the HTML and as such it has to follow the HTML rules. It needs to be somewhere inside of either the HEAD or BODY elements.

SAFX
07-23-2003, 10:13 AM
Thanks!