1

The basic structure of my page is

   body
       div id="content"
          nav
          article id="spa"
             noscript

I searched the docs page for noscript but found nothing. I'm not even sure what the error message is suggesting I should do since the noscript tag is already inside a body tag. The page displays and works properly. When js support is turned off the appropriate message is displayed. I tried moving the noscript tag to just below the body tag but the same warning is issued.

As part of posting this message I took the contents of my html page, including the open and close body tags, pasted it into jsFiddle and it came up clean. This may be specific to Visual Studio 2012 and the JSLint.VS2012 extension. I also didn't see a way in the JsLint options to disable this check.

4

1 回答 1

1

That warning does indeed come from JSLint, although not the latest version – warnings for HTML and CSS code were removed from JSLint quite recently.

I'm not sure why JSLint insists a <noscript> tag can only go in those places. The HTML 5 spec says it can go anywhere "phrasing content" is allowed, which is basically all the main content.

JSLint is very very picky. So while it's possible the warning exists because some legacy browsers have trouble with <noscript> in other locations... it's equally likely it's just a personal pet peeve of JSLint's creator, Douglas Crockford.

If you want to eliminate all JSLint warnings and you can't move the <noscript> tag up to the body, you could always use a regular visible element that's hidden by JS code if the JS gets a chance to run. Like this: http://jsfiddle.net/jJNDa/

于 2013-04-22T02:27:01.067 回答