3

I have a site that relies heavily on JavaScript and uses jQuery throughout.

I'm not going to attempt to make the site work for those who don't have JavaScript enabled.

However, I would like to show a banner at the top of the page which tells them the site is intended for use with JavaScript enabled and perhaps a modern browser, etc.

I was thinking of just putting a PHP include on all pages that contains a <noscript> with the banner inside that. Is this is good approach or is there a better way?

4

3 回答 3

6

<noscript> is the way to go.

You should also provide links to other, better browsers in the <noscript> tag if you can detect that's a browser without JavaScript.

If you wish to be more drastic about it, start with the markup <body class="nojs"> and, onload remove that class with JavaScript.

You could then have body.nojs #wrapper { display: none; }, body.nojs #notice { display: block } in your CSS.

于 2011-05-31T07:52:28.023 回答
0

Maybe How to know and handle disabled JavaScript in the browser can help you.

于 2011-05-31T07:48:58.283 回答
0

That is definitely one alternative...

Another is to have the banner visible by default without using noscript and then a $().ready() which hides the banner for all JavaScript enabled browsers.

于 2011-05-31T07:51:29.317 回答