开发者

<noscript> or something else

开发者 https://www.devze.com 2023-03-09 04:11 出处:网络
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.

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 enable开发者_JAVA技巧d 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?


<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.


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


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.

0

精彩评论

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