aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes comment? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "comment?" Watch "comment?" New topic
Author

comment?

Tina Desai
Ranch Hand

Joined: Mar 13, 2003
Posts: 365
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


Alongwith being a good coder, try to be a good professional as well!
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
<!--
Means if I am a browser that does not understand javascript then skip me.
You really do not need it.
-->
sunitha reghu
Ranch Hand

Joined: Dec 12, 2002
Posts: 937
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

Joined: Mar 13, 2003
Posts: 365
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

Joined: Sep 02, 2003
Posts: 135
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

Joined: Sep 02, 2003
Posts: 135
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

Joined: Jan 10, 2002
Posts: 60056
    
  65

It was a common practice. I don't see it much anymore. How many modern browsers don't support Javascript?
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: comment?
 
Similar Threads
Pulling data from the days of past
Problem with Ajax autocomplete Tag
how to call js file from jsp
javascript include src path not right
popup to confirm delete doesn't work on all situations