By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,847 Members | 2,321 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,847 IT Pros & Developers. It's quick & easy.

problem including .js

mickey0
100+
P: 142
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:
Expand|Select|Wrap|Line Numbers
  1. Error: missing ; before statement
  2. Source Code: http://localhost/javas.js
  3. Row: 1, Column: 5
  4. Source Code:
  5.  200 Document Follows
  6.  
I tried to do javas.js empty: the same error: where can be the error?
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script language="javascript" src="javas.js"> </script> //without this all is ok
  4. <script>
  5. function myFunc () {
  6.        for (var i=0; i < 100; i++) {
  7.             var table = document.getElementById("intro");  
  8.             var row = document.createElement("tr");
  9.             var cell = document.createElement("td");
  10.             var link = document.createElement("a");    
  11.             link.setAttribute("href", "http://www.google.com");
  12.             var linkText = document.createTextNode(" HI ");     
  13.             link.appendChild(linkText);
  14.             cell.appendChild(link);
  15.             row.appendChild(cell);
  16.             table.appendChild(row);        
  17.     }
  18. }   
  19. </script>
  20.  
  21.  </head>
  22.  <body onload="myFunc()">
  23.     <table style="width: 100%" border="5" >
  24.        <tr><td>  Rsult </td> </tr>
  25.         <tbody id="intro"> </tbody>
  26.     </table>
  27. </body>
  28. </html>
  29.  
However: the content in the page appear properly (only I'd like include a js. to do other thing)

thanks
Jan 30 '08 #1
Share this Question
Share on Google+
7 Replies


acoder
Expert Mod 15k+
P: 16,027
Have you got script tags within the JavaScript file?
Jan 31 '08 #2

mickey0
100+
P: 142
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)
Jan 31 '08 #3

acoder
Expert Mod 15k+
P: 16,027
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?
Jan 31 '08 #4

mickey0
100+
P: 142
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.....
Jan 31 '08 #5

acoder
Expert Mod 15k+
P: 16,027
Which web server software are you using?
Jan 31 '08 #6

mickey0
100+
P: 142
Which web server software are you using?
I using this minimal
http://www.cafeaulait.org/books/jnp3...TTPServer.java
Repeat: it works with html without .js. Maybe any changes has to do? thanks.
Jan 31 '08 #7

acoder
Expert Mod 15k+
P: 16,027
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.
Jan 31 '08 #8

Post your reply

Sign in to post your reply or Sign up for a free account.