开发者

Do you still Hide from browsers that do not support JavaScript? [closed]

Closed. This question is off-topic. It is not currently accepting answers.

Want to improve this question? Update the question so it's on-topic for Stack Overflow.

开发者_高级运维

Closed 11 years ago.

Improve this question

Some of the examples I'm reading start with:

<script language="javascript" type="text/javascript">
<!-- Hide from browsers that do not support JavaScript
// --> Finish hiding
</script>
  1. Do you still wrap your js code in html comments?
  2. Do you still include language="javascript"?
  3. Do you still include type="text/javascript"?


You can just use <script>...</script>

There is one more attribute available: <script charset="utf-8"> Specifying a charset for a SCRIPT is useful only if it differs from the page. The page charset is defined in the HEAD tag by:
<meta charset="..." />

And in the quest of removing unnecessary things: To avoid the onload, document...ready and friends, just place the SCRIPT tag that starts your app at the end of the BODY tag. All JS files in the HEAD and the DOM are loaded and ready to be used.

  <html>
    <head>
      <script src="lib.js"></script>
    </head>
    <body>
      ...
      <script>
        //start your app here
      </script>
    </body>
  </html>


1: No. The onload browsers that don't support JavaScript and still exist just ignore what's in the script tag. 2: No. It's depreciated. The only use what to say to IE you were using JavaScript and not VBScript but nowadays it just assumes it. 3: With HTML5, you don't need it anymore in order to pass the validator but even before, it was useless. More informations : https://developer.mozilla.org/En/HTML/Element/Script

The only one thing about script tags nowadays is you shouldn't use the stand-alone form.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜