How to change Google logo's href

血红的双手。 提交于 2019-12-25 05:48:06

问题


I would like to change the “Click to see this area on Google Maps” link, but I can't select the proper a tag.

Thanks


回答1:


You can take advantage of RobH's answer

var anchors = document.getElementsByTagName('a'),
    l = anchors.length,
    i,
    a;

for (i = 0; i < l; i++) {
    a = anchors[i];
    if (a.href.indexOf('maps.google.com/maps?') !== -1) {
         // here you can manipulate the anchor
         a.title = ''; 
         a.onclick = function () { return false; };
    }
}

NOTE

Remember It's against the Google Maps API ToS to remove the Google branding or the ToS link.




回答2:


I noted that changing the href is not desirable because every time the map is dragged or zoomed in/out, the href is set to a new value. So setting an event, as suggested in davcs86's answer, is the best approach.

Here is the code:

$(document).on("mousedown", "a[href$='mapclient=apiv3']", function(){
  $(this).attr("href", "http://NEW-URL-YOU-WANT");
});

I used onmousedown instead of onclick because it responds to the middle button.



来源:https://stackoverflow.com/questions/32281913/how-to-change-google-logos-href

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!