开发者

Google related bar - how to keep from showing up on my website

开发者 https://www.devze.com 2023-03-25 21:12 出处:网络
A new \"google related\" bar shows up at the bottom of my website.I开发者_C百科t displays links to my competitors and other things like maps, etc.It is tied in with users using the google toolbar.If a

A new "google related" bar shows up at the bottom of my website. I开发者_C百科t displays links to my competitors and other things like maps, etc. It is tied in with users using the google toolbar. If anyone has any ideas on how I can disable from displaying on my web side I would sure appreciate it.


Taken from http://harrybailey.com/2011/08/hide-google-related-bar-on-your-website-with-css/

Google inserts an iframe into your html with the class .grelated-iframe

So hiding it is as simple as including the following css:

iframe.grelated-iframe {
    display: none;
}


Google removed div and frame names and put everything to important so original answer no longer works on my site. We need to wait for the iframe to be created and then hide it by classname. Couldn't get .delay to work, but this does...today anyway.

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


Following javascript code tries to find the google related iframe as soon as the window finishes loading. If found, it is made hidden, else an interval of one second is initialized, which checks for the specified iframe and makes it hidden as soon as it is found on page.

$(window).load(function (){
var giframe = null;
var giframecnt = 0;
var giframetmr = -1;

giframe = $("body > iframe.notranslate")[0];
if(giframe != null)
    $(giframe).css("display", "none");
else
    giframetmr = setInterval(function(){
        giframe = $("body > iframe.notranslate")[0];
        if(giframe != null) {
            clearInterval(giframetmr);
            $(giframe).css("display", "none");
        } else if(giframecnt >= 20)
            clearInterval(giframetmr);
        else
            giframecnt++;
    }, 1000);});


Find the parent DIV element that contains the stuff in the bar. If it has an id or name attribute, and you can control the page CSS then simply add a rule for the element, i.e. if you see something like

<div id="footer-bar-div".....

then add a CSS rule

#footer-bar-div {display:none ! important}

This will not work if the bar is inside an iframe element, but even in that case you should be able to hide it using javascript, but you will need to find the name/id of the frame, i.e.:

var badFrame = document.getElementById('badFrameId').contentWindow;
badFrame.getElementById('footer-bar-div').style.display='none';

if the frame has a name, then instead you should access it with:

var badFrame = window.frames['badFrameName']

There is also a chance that the bar is generated on-the-fly using javascript. If it is added to the end of the page you can simply add a <noscript> tag at the end of your content - this will prevent the javascript from executing. This is an old trick so it might not always work.

0

精彩评论

暂无评论...
验证码 换一张
取 消