Go Back   vb.org Archive > vBulletin Article Depository > Read An Article > Programming Articles
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Hide certain things from users that have javascript disabled
Lea Verou
Join Date: Jul 2005
Posts: 1,856

 

Greece
Show Printable Version Email this Page Subscription
Lea Verou Lea Verou is offline 11-13-2007, 10:00 PM

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!
Reply With Quote
  #2  
Old 11-14-2007, 11:38 AM
yoyoyoyo's Avatar
yoyoyoyo yoyoyoyo is offline
 
Join Date: Dec 2004
Location: USA
Posts: 1,612
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 11-14-2007, 11:47 AM
Lea Verou Lea Verou is offline
 
Join Date: Jul 2005
Location: Greece
Posts: 1,856
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by yoyoyoyo View Post
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...
Reply With Quote
  #4  
Old 11-15-2007, 02:38 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Nice job Michelle!
Reply With Quote
  #5  
Old 11-15-2007, 02:43 PM
ragtek ragtek is offline
 
Join Date: Mar 2006
Location: austria, croatia
Posts: 1,630
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

jea cool
much nicer then my idee http://www.developer-network.org/showthread.php?t=40
Reply With Quote
  #6  
Old 11-15-2007, 04:02 PM
yoyoyoyo's Avatar
yoyoyoyo yoyoyoyo is offline
 
Join Date: Dec 2004
Location: USA
Posts: 1,612
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Michelle View Post
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
Reply With Quote
  #7  
Old 11-15-2007, 04:42 PM
Analogpoint's Avatar
Analogpoint Analogpoint is offline
 
Join Date: Feb 2007
Posts: 656
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Michelle View Post

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.
Reply With Quote
  #8  
Old 08-29-2008, 12:32 AM
dartho dartho is offline
 
Join Date: Sep 2005
Location: Australia
Posts: 2,303
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks you - incredibly useful!
Reply With Quote
  #9  
Old 06-10-2009, 01:17 AM
Tim Skellett Tim Skellett is offline
 
Join Date: Sep 2005
Posts: 73
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Really neat, very helpful! Many thanks!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:33 PM.


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.04146 seconds
  • Memory Usage 2,277KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_html
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_article
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (9)post_thanks_box
  • (9)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (9)post_thanks_postbit_info
  • (8)postbit
  • (9)postbit_onlinestatus
  • (9)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete