Results 1 to 13 of 13

Thread: Override html style property

  1. #1
    Join Date
    Jul 2006

    Override html style property


    im modifying a template that is kinda cryptic and idont completely understand it. I want to change colors and other things. I managed to change mostly everything except this:

    HTML Code:
    <div class="gwt-HTML" style="display: inline; color:rgb(0, 0, 0);">[TEXT GOES HERE]</div>
    I want to change the color of that text from black to white, but that rgb(0, 0, 0) doesnt let me do it with CSS and i cant just take it off since its generated by some cryptic javascript code i cant figure out so i guess the only way is to write another javascript that overrides the color:rgb(0, 0, 0) property and make it white but im not sure on how to do it. Can you give me some ideas?

    Thank you.

  2. #2
    Join Date
    Mar 2012
    In rgb notation, white is rgb(255, 255, 255) which, I think, can be abbreviated to rgb(255). The strange thing about your example is that the div does not have an ID. I have no idea how the color could be changed in JS without an ID. Are you sure that it is correct?

  3. #3
    Join Date
    Jul 2006
    Yes, its correct. And yes, its a problem it doesnt have an ID. Maybe we can do something with the class? like chaging all the elements with gwt-HTML class and that have rgb(0)? will it work?

  4. #4
    Join Date
    Nov 2010
    It has nothing to do with the rgb assignation, but rather that inline styles will override css declatations.

    There are a couple of ways around it, but the simplest (if you want all divs with the class name gwt-HTML to have white text) is to put this at the end of your body section, just before the </body> tag:

    var divs=document.getElementsByTagName("div")
    for (var i = 0; i < divs.length; i++) {

  5. #5
    Join Date
    Jul 2006
    Thanks. Actually not all of them, only the ones with rgb(0) because the background is dark, so text wont be readable in black. Also, its a chat and content is generated in real time, so i need the code to change the color dynamically everything a message appears. I wonder if thats possible.

    Thank you.

  6. #6
    Join Date
    Nov 2010
    var divs=document.getElementsByTagName("div")
    for (var i = 0; i < divs.length; i++) {
    if(divs[i].className=="gwt-HTML" && divs[i].style.color=="rgb(0, 0, 0)"){

  7. #7
    Join Date
    Jul 2006

    must i put the code like this:

    var divs=document.getElementsByTagName("div")
    for (var i = 0; i < divs.length; i++) {
    if(divs[i].className=="gwt-HTML" && divs[i].style.color=="rgb(0, 0, 0)"){
    exactly right before the </body> tag? because seems like it wont let me put it there. The parsed code shows some bits of code after whatever i put before the </body> tag. I wonder if i can put it somewhere else such as within the head tag.

    Last edited by supercain; 10-08-2012 at 01:52 AM.

  8. #8
    Join Date
    Nov 2010
    sounds like you're doing it wrong to me. it should be fine just before the </body> tag. can you show a link to your page?

    if worse comes to worst, you can put it in the head, but you would have to wrap it in a window.onload function, to give the page time to render the divs

  9. #9
    Join Date
    Jul 2006
    The problem is that i cant put it right before the </body> tag because the full code is very complex and its fully generated by javascript so i cant tell what to modify in order to get it show right there. I can put it inside head or after the <body> tag though. I will send you the link to my page by PM for security reasons. Thank you for your help.

  10. #10
    Join Date
    Nov 2010
    aaaah. I get it now. This is the problem: your page creates divs, and the code I gave you will only work on divs that have already been created. I think really your best option is editing the css - if you can't do that, you would have to look for some sort of listener that tells you when a new div has been added and run the code then.

  11. #11
    Join Date
    Jul 2006
    With css its imposible as you may see, since the style property in the div overrides the css style. However i would like to know more about that listener you say. Whats about?

    Thank you.

  12. #12
    Join Date
    Nov 2010
    it's not a simple thing, as there is no cross-browser implementation of a "DOM changed" listener (and why not, I may ask?)

    you would have to go into the code that creates the chat, find out if there is some event that happens every time a new post is made, then run that code every time it happens.

    the sleazy workaround would be to wrap the whole thing in a function and call that function every, say, half second using setInterval...

  13. #13
    Join Date
    Jul 2006
    I see. That sounds terribly complicated. The source code is a real pain in the ass. I've located the piece of code that adds the rgb property to the div. Its this:


    terribly simple, huh? if i take it off then that rgb thing disappears from the div. However, now you wont be able to change your font color. I wish i could trace the function that does all this and just set white as the default color but this level of code is too much for me.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.11870 seconds
  • Memory Usage 2,965KB
  • Queries Executed 15 (?)
More Information
Template Usage (35):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (13)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (13)postbit
  • (13)postbit_onlinestatus
  • (13)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates