【问题标题】:How to change Google logo's href如何更改 Google 徽标的 href
【发布时间】:2015-11-23 18:09:24
【问题描述】:

我想更改“单击以在 Google 地图上查看此区域”链接,但我无法选择正确的 a 标记。

谢谢

【问题讨论】:

    标签: google-maps-api-3 jquery-gmap3


    【解决方案1】:

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

    代码如下:

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

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

    【讨论】:

      【解决方案2】:

      您可以利用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 链接是违反 Google Maps API ToS 的。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2021-12-15
        • 1970-01-01
        • 1970-01-01
        • 2018-05-18
        • 2016-08-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多