User login

Drupal adds class js to html tag when JavaScript is enabled

texas-bronius: What's the best way to provide css for non-js-enabled browsers that differs for css for js-enabled?
17:13 texas-bronius: hi benjamin-agaric welcome back
17:15 benjamin-agaric: texas-bronius: hi. Assign the classes themselves with JavaScript?
17:15 texas-bronius: benjamin-agaric: duh. Yes, good idea thanks. Class name could be "hasjs" or something.
17:17 texas-bronius: benjamin-agaric and anyone else listening in: Looks like Drupal already does provide a class="js" on the root html node-- it eluded me earlier because it doesn't show in source, only post-javascript! :D woo hoo

Update: There's also a js-hide class which will hide anything that has that class when JavaScript is enabled.

benjamin-agaric: texas-bronius: mind if this self-discovery gets posted to data.agaric.com?
texas-bronius: benjamin-agaric: not sure what you mean? ..
benjamin-agaric: texas-bronius: i post every piece of useful information i come across -- usually it's something i had trouble with, but sometimes its something i see come across irc -- because i know i'll be needing it later
texas-bronius: benjamin-agaric: If you want to blog "Drupal adds class js to html tag" heck yeah go ahead-- wish you'd done it earlier! :D
benjamin-agaric: and it's useful to some other people do
benjamin-agaric: texas-bronius: exactly!
texas-bronius: but cite:
texas-bronius: http://www.lullabot.com/articles/bitchin-search-box
texas-bronius: where I first thought ot learn about this-- it only just occurred to me now why I was unable to see it 'til now :D

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.