0

Possible Duplicate:
HTML comments in a javascript block?

Hello im cleaning a web page from comments and other stuff.

I just found this <!-- but i dont understand why start with <!-- and close with -->

I use that to comment out something on html.. but here?? look at it

<script type="text/javascript"><!--
$("ul.menubbcl").superfish({        
    animation: {height:'show'},   // slide-down effect without fade-in 
    delay:     1000,           // 1.0 second delay on mouseout
    autoArrows : true 
}); 
//--></script>

Can somebody explain me this. pls

8
  • 3
    To support very old browsers which would render the script as text in the page rather than execute it. Commented Jan 14, 2013 at 2:38
  • 1
    Your my hero!, thanks ;) really i ask just a minute ago jajaja Commented Jan 14, 2013 at 2:39
  • Funny thing: the snippet uses jQuery, but I don't think even jQuery supports such old browsers (although it probably degrades gracefully). Commented Jan 14, 2013 at 2:40
  • Wait, doesn't this will create a SyntaxError for <!--? Commented Jan 14, 2013 at 2:48
  • 1
    @Jeff - I tried window;<!--;window; and it comes out ok, so I guess the browser just ignores it. Commented Jan 14, 2013 at 3:29

1 Answer 1

0

This is for browsers that do not support Javascript. Supplying HTML comment tags around it will prevent it from being rendered as text in such browsers.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks!! always great to learn something new
@Monclee Don't forget to accept the appropriate answer using the "tick" button on the left :)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.