Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display "Enable JavaScript" message only when JavaScript is disabled

I want to display to the user a message that says "please enable JavaScript" in the case that JavaScript is disabled. I want that message, and nothing else to be displayed when JavaScript is disabled.

So, to do this, I can put the message in the DOM and hide all other elements with display:none. Then in JavaScript I can set the message to display hidden and show all other elements.

But I get a flicker with this approach. The error message shows up for a while (especially on mobile browsers) before it gets hidden.

How can I minimize the time the error message is displayed for?

like image 502
Michael Avatar asked Mar 17 '11 02:03

Michael


People also ask

Which tag will display message if JavaScript is not enabled?

To detect if JavaScript is disabled in a web browser, use the <noscript> tag. The HTML <noscript> tag is used to handle the browsers, which do recognize <script> tag but do not support scripting. This tag is used to display an alternate text message.

What happens if JavaScript is disabled?

Javascript is enabled in your web browser. If you disable JavaScript, this text will change.

How do I know if JavaScript is blocked?

First, click on the "Security" tab. Under the "Web content" section, you'll see a box next to "Enable JavaScript." If the box is unchecked, that means JavaScript has been disabled.


1 Answers

You're looking for the <noscript> tag.

like image 60
SLaks Avatar answered Nov 15 '22 04:11

SLaks