vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Programming Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=188)
-   -   Hide certain things from users that have javascript disabled (https://vborg.vbsupport.ru/showthread.php?t=162673)

Lea Verou 11-13-2007 10:00 PM

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

yoyoyoyo 11-14-2007 11:38 AM

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.

Lea Verou 11-14-2007 11:47 AM

Quote:

Originally Posted by yoyoyoyo (Post 1382316)
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...

Analogpoint 11-15-2007 02:38 PM

Nice job Michelle!

ragtek 11-15-2007 02:43 PM

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

yoyoyoyo 11-15-2007 04:02 PM

Quote:

Originally Posted by Michelle (Post 1382322)
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:
https://vborg.vbsupport.ru/showthread.php?t=141584

Analogpoint 11-15-2007 04:42 PM

Quote:

Originally Posted by Michelle (Post 1382322)

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.

dartho 08-29-2008 12:32 AM

Thanks you - incredibly useful!

Tim Skellett 06-10-2009 01:17 AM

Really neat, very helpful! Many thanks!


All times are GMT. The time now is 10:59 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01187 seconds
  • Memory Usage 1,728KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_html_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (9)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete