Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Change CSS attribute on facebook with javascript?

    Hello. I want to change my facebook page a little (by adding javascript to my bookmarks and executing it on the facebook site).
    Since I really know nothing about javascript (all I know is HTML, CSS and Delphi(from school)) I just searched for examples and then adjusted them to my needs.

    I used this to change the color of the bar at the top:
    Code:
    javascript:document.getElementById('blueBar').style.background='rgb(20,20,20)';return false;
    Now the icons have a different color aswell so I want to replace the image for those.

    Code:
    #fbRequestsJewel a.jewelButton {
    background-image: url(https://fbstatic-a.akamaihd.net/rsrc...GXomUrjl.png);
    background-repeat: no-repeat;
    background-size: auto;
    background-position: 0 -220px;
        }
    This is where I'd need to change the background-image to one of my own links where I recolored the icons. How do I access that attribute with javascript?

    Would be great if anyone could help me out here.

  • #2
    New to the CF scene
    Join Date
    Jun 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    bump.

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,020
    Thanks
    75
    Thanked 4,323 Times in 4,289 Posts
    Try this:
    Code:
    var links = document.getElementById("fbRequestsJewel").getElementsByTagName("a");
    for ( var i = 0; i < links.length; ++i )
    {
        if ( (/jewelButton/i).test(links[i].className) )
        {
            links[i].style.backgroundImage = "url(http://xxx.com/zzz/image.png)";
        }
    }
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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