Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript stylesheet change if javascript is enabled

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #36352
    marcdefiant
    Participant

    Hey guys.
    My site I’ve been working on needs javascript to display properly.
    It has a width of 906px and the sidebar is on the left. The whole left of the page is the same background color as the sidebar background color, so, I javascript needs to be enabled for it to display properly.

    Currently, this is my solution:

    $('#stylesheet').attr('href', '/style.css');

    is this bad practice? is there a better way of doing this?

    thanks in advance guys

    #95593
    TheDoc
    Member

    I think I would be using some sort of < noscript> thing. Don’t know enough about JS though!

    #95601
    jamygolden
    Member

    Check out Modernizr.
    A class of ‘no-js’ must be given to the <html> element for the plugin to take effect. If it loads and fires correctly (javascript enabled) that class is removed and other classes are added to the html element (read about modernizr to find out more about that). Very basically though, you can use .no-js to style your web-page for people who don’t have it enabled.

    .no-js #main-content { display: none; }
    .no-js #js-disabled { display: block; }

    those are just two small examples, but you get the idea.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.