Helpful Information
 
 
Category: Programming Articles
Hide certain things from users that have javascript disabled

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. :D

Instructions
Open your headinclude template and add this code at the very bottom:

<!-- 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:
<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! :D

great idea - I will have to try it out later. very simple javascript, but seems like it would be effective. It seems like this could easily be converted to BB code, also.

great idea - I will have to try it out later. very simple javascript, but seems like it would be effective. It seems like this could easily be converted to BB code, also.
In fact it doesn't use any javascript, it just uses the <noscript> tags to define a css class that will hide anything that has it. However the browser only "sees" that class if the javascript is disabled, since the <style> tags are inside <noscript> tags. ;)

Why would someone want to convert this to a bbcode? I can't think of any use of such a bbcode...

Nice job Michelle!

jea cool
much nicer then my idee:D http://www.developer-network.org/showthread.php?t=40

Why would someone want to convert this to a bbcode? I can't think of any use of such a bbcode...here is one example:
http://www.vbulletin.org/forum/showthread.php?t=141584

Why would someone want to convert this to a bbcode? I can't think of any use of such a bbcode...

You could combine it with any BBCode that uses Javascript, such as a spoiler tag.

Thanks you - incredibly useful!

Really neat, very helpful! Many thanks!










privacy (GDPR)