如何更改 Google 徽标的 href

How to change Google logo's href

我想更改“单击以在 Google 地图上查看此区域”link,但我无法 select 正确的 a 标签。

谢谢

你可以利用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; };
    }
}

注意

记住,删除 Google 品牌或 ToS link.

违反 Google 地图 API ToS

我注意到更改 href 是不可取的,因为每次拖动或缩放地图时 in/out,href 都会设置为新值。因此,按照 davcs86 的回答中的建议设置事件是最好的方法。

代码如下:

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

我使用 onmousedown 而不是 onclick 因为它响应中间按钮。