Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can't find syntax error in stmt

    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.

    -----------------------------------------------------

    <body>

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

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



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

  • #2
    New Coder
    Join Date
    Jun 2002
    Location
    yorkshire, uk
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

    neil.c

  • #3
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.




    <!-- DEFINE FUNCTION FOR POPUP PHOTO WINDOW -->

    <script>
    function openpopup(popurl){
    winpops=window.open(popurl,"","width=320,height=320")
    }
    </script>

  • #4
    New Coder
    Join Date
    Jun 2002
    Location
    yorkshire, uk
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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:

    Code:
    // DEFINE FUNCTION FOR POPUP PHOTO WINDOW
    
    function openpopup(popurl){
    winpops=window.open(popurl,"","width=320,height=320")
    }
    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?
    neil.c

  • #5
    New to the CF scene
    Join Date
    Jul 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Solved

    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •