Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You must have JS enabled message?

What's the best way to implement a "you must have JS enabled" message? My site simply won't work without JS at the moment.

Should I use the <noscript> tag? Should I hide the entire page's content, put a message about needing JS enabled, and then hide the message and show the content with JS? -- This might cause the message to be temporarily visible.

Is there a site I can direct my users to that describes how to enable JS in different browsers? Maybe a blurb about that stupid noscript FF addon too?

like image 666
mpen Avatar asked Feb 27 '23 05:02

mpen


2 Answers

Use the noscript tag, that will only be visible when scripting is unavailable (i.e. disabled).

Additionally, you can initially hide some features using css and enable them with script.

Enabling scripting is specific for each browser, so you might have to link to several pages to cover all browsers used in your target group. This Microsoft page covers some of the most popular.

like image 127
Guffa Avatar answered Mar 07 '23 14:03

Guffa


you could also hide the wrapper in the content like

<body>
    <div class="js-on">
       ...content here
    </div>
    <div class="js-off">
      warning: you must have javascript enabled
    </div>
</body>

.js-on{display:none;}
.js-off{display:block;}

and remove/toggle both classes with javascript. ;)

but as a fallfack for browsers that do not support css:

      <noscript>

-tag is the best solution

like image 42
Caspar Kleijne Avatar answered Mar 07 '23 16:03

Caspar Kleijne