View Full Version : Can't find syntax error in stmt

07-26-2002, 09:20 PM
IE says there's a Run Time error and
further says it's a syntax error in the
statement beginning: "<script language= "

If I comment it out, there is no error, so it
must be this statement. Please... do you
see an error??

Thank you.



<!-- points to location of script popup window used to display jpgs -->

<script language="JavaScript" type="text/javascript" src="indjs.js">

<a name="top"></a>
<body bgcolor="#cccccc" link=blue alink=red vlink=blue>

07-26-2002, 09:57 PM
i don't see an error, looks fine to me, but your browser might do. here are some ideas:

1. try a different browser

2. i always put external javascripts in the head, just because i only really use them for functions and so it's best to load them in advance. i've never tried putting one in the body, maybe they're not allowed there. seems stupid but you never know.

3. try taking out the type="text/javascript" param, maybe it doesn't like it there as well as a language param.

4. (most likely, i think) is it definetely referring to this line in the html? i'm thinking the syntax error is actually in the external .js. this way, if you comment out the script tag, of course it will stop cos the script with the error is never loaded. im assuming the error is 'syntax error at line whatever', have a look at this line in your .js.


07-26-2002, 10:19 PM
I had it in the HEAD first and moved it to the BODY
to see if anything changed. It didn't.

Here's the 81st line of the indjs.js
script... which is where the browser reports
the error... i.e. "Line 81"

Do you see a syntax error there?

Thank you.


function openpopup(popurl){

07-27-2002, 12:12 PM
i didn't see any problem when i first looked at that, cos its not strictly a syntax error.

you don't put <script> tags in .js files.

when the browser comes to a <script> tag it expects everything it reads to be in javascript until it finds a </script> tag. if you put a src="*.js" parameter in, the browser loads the .js file and uses it exactly as if the code was in the html document, between <script> and </script> tags.

so in other words, you can't put any html tags in external .js files. all they can contain is pure javascript. rewrite your poup function like this:


function openpopup(popurl){

if you've got any more html tags in your .js file - these might be <script> or even <!--comment--> tags, take them out.

any luck?:thumbsup:

07-27-2002, 05:59 PM
Yes, that's exactly what was wrong.

I found other HTML comments in the *.js file
which had been there for years; apparently
some browsers will overlook html comments.

Thank you.