1

If possibility to checking in CSS detect browser support javascript ? or set other CSS Media Queries for browser not support javascript ?

4
  • All browsers support JS. Are you asking to detect if it's turned off? Commented Mar 7, 2014 at 11:32
  • css alone doesn't detect if js is turned on. You need to use also js Commented Mar 7, 2014 at 11:33
  • e.g: google boot or js is turned off Commented Mar 7, 2014 at 11:34
  • Modernizr.js .no-js .tabs-content > .content {display: block !important;} result: <html class="no-js" > Commented Mar 7, 2014 at 11:38

2 Answers 2

3

You can do it without javascript. You have to use ... HTML !

There is a tag for that : noscript

Summary :

The HTML <noscript> Element defines a section of html to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.

Example :

<noscript>
    <!-- this content will be display if no js -->
</noscript>

In your case, I think you will need something like this :

<noscript>
    <link rel="stylesheet" type="text/css" href="css/nojs.css" />
</noscript>

if you want more info about it, this topic on SO is pretty good.

Sign up to request clarification or add additional context in comments.

Comments

0

The common way is to add a class called no-js to your , e.g.

<head class='no-js'>

then as your first line of JS, remove the class.

To keep it simple, in jQuery you'd then write:

$("head").removeClass("no-js");

If you are using plain JS, you need to parse the class attribute and remove just the no-js bit, else if you add further classes later you will wipe them out with a naive approach.

You can then write CSS like:

.message {
    display:none;
}

.no-js .message {
    display:block;
}

If you wanted to show an element with class message only to people with JS disabled.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.