Back to Programming Articles

Hide certain things from users that have javascript disabled
by Lea Verou 14 Nov 2007
Rating: (2 votes - 4.50 average)

Hide certain things from users that have javascript disabled
I needed this for a project I'm working on, and thought I'd share it, as I liked my idea a lot.

Instructions
Open your headinclude template and add this code at the very bottom:
HTML Code:
<!-- is js enabled? -->
<noscript>
    <style type="text/css">
        .ifjs { display:none; }
    </style>
</noscript>
<!-- / is js enabled? -->
Then you can add the class ifjs to any element you want to be hidden from visitors that have disabled javascript. For example:
HTML Code:
<div class="ifjs">visitors with disabled js won't see this</div>
<div class="alt1 ifjs">visitors with disabled js won't see this</div>
You can even use it in non-vbulletin pages (as long as you put that code in the head) as it doesn't use any vB-specific code.
Feel free to go crazy with javascript now and not worry about those morons who disable it!

vblts.ru supports vBulletin®, 2022-2024