Professional Web Development Forums: Using Comments - Professional Web Development Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Using Comments how to use the correct commenting Rate Topic: -----

Posted 05 March 2010 - 09:16 AM (#1) User is offline   Newt 

  • Member
  • Group: Members
  • Posts: 438
  • Joined: 18-November 08

in the past ive been using this way

<!-- code //-->


but only today i was told it was this way

<!-- code -->


which is the right way? this is ot a spammy post its a genuine question.
0

Posted 05 March 2010 - 10:41 PM (#2) User is offline   Bobby 

  • Member
  • Group: Members
  • Posts: 95
  • Joined: 01-February 09
  • Gender:Male
  • LocationNew Hampshire, USA

View Postnewt, on 05 March 2010 - 09:16 AM, said:

in the past ive been using this way

<!-- code //-->


but only today i was told it was this way

<!-- code -->


which is the right way? this is ot a spammy post its a genuine question.


HTML comments are ended with "-->". The two slashes you sometimes see are only used within a JavaScript block. For example:

<script type="text/javascript">
<!--

// JS CODE

//-->
</script>


JavaScript single-line comments are initiated with "//". As such the two slashes is just there to make sure the script doesn't read that line (it'll automatically ignore the first line with "<!--").

Commenting out JavaScript blocks like above is now a thing of the past; has been for years. But many authors, myself included, will still do it out of sheer habit.

This post has been edited by bhensley: 05 March 2010 - 10:41 PM

0

Posted 06 March 2010 - 08:04 AM (#3) User is offline   Newt 

  • Member
  • Group: Members
  • Posts: 438
  • Joined: 18-November 08

what is the way to stop a browser show js if js is disabled?
0

Posted 06 March 2010 - 03:00 PM (#4) User is offline   ElseAndrew 

  • English & Proud -__-
  • Group: Moderator
  • Posts: 1,919
  • Joined: 12-February 09
  • Gender:Male

Wrap it in <noscript> tags.

<noscript> It looks like you don't hava JavaScript enabled... Click HERE to learn to how enable it...</noscript>

<script>

//Javascript code

</script>
Posted Image
0

Posted 06 March 2010 - 08:55 PM (#5) User is offline   Bobby 

  • Member
  • Group: Members
  • Posts: 95
  • Joined: 01-February 09
  • Gender:Male
  • LocationNew Hampshire, USA

View PostElseAndrew, on 06 March 2010 - 03:00 PM, said:

Wrap it in <noscript> tags.

<noscript> It looks like you don't hava JavaScript enabled... Click HERE to learn to how enable it...</noscript>

<script>

//Javascript code

</script>


The noscript element merely provides an alternative if scripting is disabled. You shouldn't be wrapping a script element inside noscript; merely use the two side-by-side.

All modern day browsers handle the script element properly, even if scripting is disabled. The contents will never be broad casted to the screen. As such, commenting them out is useless.
0

Posted 11 March 2010 - 04:55 AM (#6) User is offline   fg101 

  • New Member
  • Group: Members
  • Posts: 25
  • Joined: 10-March 10
  • Gender:Male

why do we still hav the noscript if its not functional anymore? thnx everyone
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic


1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Enter your sign in name and password


Sign in options
  Or sign in with these services