Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show message if javascript is not enabled in the browser

I'm looking for a solution to show the visitor of my website an info message, if he has no javascript enabled. I tried it with a message in a div, that is visible by default but immediately hidden by a jQuery function on start up. The problem is, that the message is visible for a short time (until it is hidden), what is very irritating.

Are there other ways to show a message, if JS is not enabled?

Thanks, Konrad

like image 807
Konrad Avatar asked Feb 22 '12 08:02

Konrad


People also ask

Which tag will display message if JavaScript is not enabled?

The <noscript> tag defines an alternate content to be displayed to users that have disabled scripts in their browser or have a browser that doesn't support script. The <noscript> element can be used in both <head> and <body>.

How do I know if JavaScript is turned off?

On the web browser menu click on the "Edit" and select "Preferences". In the "Preferences" window select the "Security" tab. In the "Security" tab section "Web content" mark the "Enable JavaScript" checkbox. Click on the "Reload the current page" button of the web browser to refresh the page.


1 Answers

Use the noscript tag:

<noscript>

  <div class="awesome-fancy-styling">
    This site requires JavaScript. I will only be visible if you have it disabled.
  </div>
  ...
</noscript>

See https://developer.mozilla.org/en/HTML/Element/noscript.

like image 183
Jakub Hampl Avatar answered Oct 20 '22 00:10

Jakub Hampl