problem including .js

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mickey0
    New Member
    • Jan 2008
    • 142

    problem including .js

    hello,
    I'm writing my own web server that take a query and respond with the page;
    It seems OK. FF nothing console errors.
    Problem is when I tried to include in my file html a file "javas.js": FF gets strange error as:
    Code:
    Error: missing ; before statement
    Source Code: http://localhost/javas.js
    Row: 1, Column: 5
    Source Code:
     200 Document Follows
    I tried to do javas.js empty: the same error: where can be the error?
    Code:
    <html>
    <head>
    <script language="javascript" src="javas.js"> </script> //without this all is ok
    <script>
    function myFunc () {
           for (var i=0; i < 100; i++) {
                var table = document.getElementById("intro");  
                var row = document.createElement("tr");
                var cell = document.createElement("td");
                var link = document.createElement("a");    
                link.setAttribute("href", "http://www.google.com");
                var linkText = document.createTextNode(" HI ");     
                link.appendChild(linkText);
                cell.appendChild(link);
                row.appendChild(cell);
                table.appendChild(row);        
        }
    }   
    </script>
    
     </head>
     <body onload="myFunc()">
        <table style="width: 100%" border="5" >
           <tr><td>  Rsult </td> </tr>
            <tbody id="intro"> </tbody>
        </table>
    </body>
    </html>
    However: the content in the page appear properly (only I'd like include a js. to do other thing)

    thanks
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    Have you got script tags within the JavaScript file?

    Comment

    • mickey0
      New Member
      • Jan 2008
      • 142

      #3
      sorry, I don't know what you mean; script tags inside js file? like as <script> </script>; if you mean this, no i haven't it, only javascript code. Why?
      But the problem is that the server don't display properly th page whenever I have the "line" that include include that file (it doesn't work even if the file is empty)

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Yes, that's what I meant. That could possibly have been the cause of this error.

        When you have the error on row 1, column 5, what are the contents of the JS file?

        Comment

        • mickey0
          New Member
          • Jan 2008
          • 142

          #5
          sorry I forget...The page is displayed properly on local. The problem arise only when i lauch my web server and those strange errror occur....It seems that with this web server I can't include external file.....

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Which web server software are you using?

            Comment

            • mickey0
              New Member
              • Jan 2008
              • 142

              #7
              Originally posted by acoder
              Which web server software are you using?
              I using this minimal

              Repeat: it works with html without .js. Maybe any changes has to do? thanks.

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                I'm leaving this thread here to deal with the JavaScript aspect of the problem, but I've also copied it over to the Java forum.

                Comment

                Working...