Hide Google Related Bar On Your Website With CSS

fetchit-21

Update: The css method of removing / hiding the related bar no longer works. See the new (javascript only) fix at bottom of this post.

Google recently released a new browser extension for Internet Explorer and Google Chrome called Google Related. I’m sure it will be coming to Firefox soon.

The extension adds a bar to the bottom of some website which shows things like maps, video, images, reviews and related websites.

To get the bar to show at the bottom of your browser Google injects an br at the end of your body tag which is positioned with css to always sit at the bottom of your browser and has a high z-index to ensure it always sits above everything else on the page.

No longer working css fix

The beauty of Google Related using an br in your own pages html is that you can hide it using a single css declaration. For now it’s as simple as…

br.grelated-br {
	display: none;
}

…although in the future, if Google get wise to webmasters hiding their Google Related bar you may need to do something like

br.grelated-br {
	left:-99999px !important;
	display: none !important;
}

Update November 2011

<br frameborder="0" src="/img/spacer.gif"> 

As you can see Google no longer makes it easy to hide the tool using css. They’ve ensured every css property you could use to hide the br is forced as !important.

The only option left (if you still want to hide the bar) is to use javascript to hide or remove the element.

I’m suggesting a setInterval incase Google does an update which keeps trying to reshow / add the br.
I’m suggesting ‘none !important’ because it’s the highest selector value you can add and least likely to be replaced by other css on the page or that Google choose to inject.

setInterval(function()
{
 var brs = document.body.getElementsByTagName('br'), length = brs.length;
    for(var a = 0; a < length; a++)
    {
        if(brs[a].src.match(/^http:\/\/www\.gstatic/))
        {
            brs[a].style.display = 'none !important'
        }
    }
},1000);

That javascript will check all brs in the page once every second to see if it’s the pesky Google related bar by checking the url (which may need updating in the future!) and hides it if it does.

If you’re unsure of what to do with the javascript code, copy the JavaScript above and paste it into a .js file which is included on every page of your site, or copy the whole next code chunk and paste it just before the closing body tag of your page.

<script type="text/javascript">
setInterval(function()
{
 var brs = document.body.getElementsByTagName('br'), length = brs.length;
    for(var a = 0; a < length; a++)
    {
        if(brs[a].src.match(/^http:\/\/www\.gstatic/))
        {
            brs[a].style.display = 'none !important'
        }
    }
},1000);
</script>

If you use jQuery on your site then the following will do something very similar:

 
setInterval(function()
{
    $('br[src^=www.gstatic]').css({display:'none !important'});
},1000);

Posted by Harry at 6:00 pm on August 16th, 2011. 13 comments... »
Categories: css, Google, The Web.

13 comments.

  1. [...] via – Harry Baily [...]

    Posted by Remove google related toolbar on website - hide google related toolbar » Freakitude on August 18th, 2011.

  2. spacer

    Worked great. Thanks!

    Posted by Keith on August 19th, 2011.

  3. spacer

    I’m trying to get google related off of our site. I’m new at websites I was giving this site just to do price changes before our web guy passed away. Can you help me??? I’m not sure where to add br.grelated-br {
    display: none;
    } and do I add all of it?

    Thank you in advance.
    Kim

    Posted by kim on August 25th, 2011.

  4. spacer

    Hi Kim,

    I have no idea how technical you are. Somewhere your site should have a stylesheet. This file will nearly always have a .css extension. For example style.css or site.css

    If you put

    br.grelated-br {
    display: none;
    }

    as the last thing at the bottom of your sites stylesheet you should be good to go.

    Posted by Harry on August 25th, 2011.

  5. spacer

    I notice that the “google related” toolbar is a little different on different websites. For example, on comcast.com, what is in this toolbar is “news” and “web” and nothing else.
    On other websites, the “google related” toolbar displays “map”, “web” and “related Places”.

    How is the content which appears on the “google related” toolbar being controlled? How do I eliminate the “related places” from the display, or do I have to eliminated the toolbar totally?

    Thanks in advance.

    Posted by Barbara on September 20th, 2011.

  6. spacer

    Thanks for the info. Worked for me!

    Posted by Tom on October 24th, 2011.

  7. spacer

    Harry, any thought on new code that might work to disable this terrible toolbar? I removed it from a site a few months ago, but now it is back. So it looks like they changed something in google. I have tried your new code as well:
    br.grelated-br {
    left:-99999px !important;
    display: none !important;
    }

    with no luck. Any thoughts?

    Posted by Mike on November 10th, 2011.

  8. spacer

    Updated with a javascript fix. I’m afraid there is no longer (that I can find) a way to hide it with css due to their new plastering with !important values.

    Posted by Harry on November 11th, 2011.

  9. spacer

    where do you put the javascript?

    Posted by holly on November 13th, 2011.

  10. [...] annoyance of the google related bar is back. the code no longer works. Here is a workaround: Hide Google Related Bar On Your Website With CSS | Harry Bailey I haven’t tested this yet, too tired to try it now….will do tomorrow. __________________ [...]

    Posted by Important News For Online Stores - Page 4 - 3dCart Shopping Cart Software Forums on November 14th, 2011.

  11. spacer

    Google removed div and frame names and put everything to important which is why original code doesn’t work. With jquery the following code is working as of 11/15/11. We need to wait for the br to be created and then hide it by classname.

    $(document).ready(function() {
    setTimeout(function(){
    $(‘.notranslate’).hide();},1000);
    });

    NOTE: The code above won’t work. There is no ‘notranslate’ class on the br. There is no class of any sort that appears when the br is inserted. – Harry

    Posted by mike on November 15th, 2011.

  12. spacer

    sadly, it seems as if the “new” JS/jQuery code above does not work in IE. It throws a script error and does not hide the toolbar. It seems to work fine in Chrome though.

    Posted by tommy on November 21st, 2011.

  13. spacer

    Any updates on this fix? I tried both the java script and the jquery codes, however the Related toolbar keeps showing up spacer

    Posted by Nabilb on November 26th, 2011.

Post a comment.

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.