Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

comment?

 
Tina Desai
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
what does this
<!--
// -->
mean in javascript? a comment?
if I have,
<script src="One.js" language="Javascript">
<!--
// -->
</script>
<script src="Two.js" language="Javascript">
<!--
// -->
</script>
what does it mean actually?
can't I directly write -
<script src="/_commonjs/CommonJavaScript.js" language="Javascript">
</script>
<script src="/_commonjs/GlobScreenIdentity.js" language="Javascript">
</script>
Thanks and Regards,
Tina
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<!--
Means if I am a browser that does not understand javascript then skip me.
You really do not need it.
-->
 
sunitha reghu
Ranch Hand
Posts: 937
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These were added because of two reasons
1. The old browsers which dont recognzie javascript scripts tag is ignored.
then it will also skip code between the comments coz its basically html commment rt.
2. the second scenario is that some users can disable javascript. but that doesnt mean that browser wont excecute that. so in those case also those will be code is between the comments then the browser will skip the code.
 
Tina Desai
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh..
If it is ok that the javascript does not get executed due to some reasons, I enclose the function in the structure. Am I right?
What is a common practice? It is always safer to enclose by JS functions likewise?
Tina
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Putting Java Script code in comments (<!-- --> is the common practice.
This prevents browser from showing javascript code in case the
user disables Java Script or in case of old browsers and
Java Script errors.
 
Idly Vada
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Putting Java Script code in comments (<!-- --> is the common practice.
This prevents browser from showing javascript code in case the
user disables Java Script or in case of old browsers and
Java Script errors.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65229
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It was a common practice. I don't see it much anymore. How many modern browsers don't support Javascript?
bear
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic