I have some client side js that works ok on one server but gives an error on another server.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
<SCRIPT LANGUAGE="JavaScript">
<!-- Start of comments to hide JavaScript Code
var var01 = "someText", boolThing=false
The browser is IE 8, the webserver is IIS
On the page where not working, I get a webpage error = expected ";" var01 is not defined.....
so that makes sense there is no ; at the end of the var declarations but as I as said above the error does not occur on one server but does on another. on the server where I get the error, just to test I put the var declarations on separate lines each with its ; at the end, and that took care of the error
so............
its the same browser, and the same code rendered on the server, any ideas how one could be ok and not the other?
and as an aside, evidently in at least this one environment js can be ok without the ; (semicolons) at the end of statements?? is that something to do with the browser being IE and really running a ms java engine and not the sun version?
@WolfShade - common misconception - you do NOT need a semi-colon at the end of the line in most circumstances. The code below works perfectly fine (in both IE8 and FF11):
Code:
<script>
var var01 = "someText", boolThing=false
alert('var01='+var01 +'\nboolThing='+boolThing)
</script>
@bbxrider - there may be something else at play. Can you post more code than what you gave us?
Bookmarks