dta25920 2018-06-05 06:55
浏览 64

您在Wordpress中悬停时隐藏或隐藏地址链接

When you hover a link in HTML, in the side left-bottom of the browser appears the link address that you are hovering.

If I have a link with UTM parameters, I don't want that address appears there, I would like that it shows me another "name" or "address".

How could I hide or cloak the address link in Wordpress ?

PD: No plugins

Any idea.

Thanks

  • 写回答

1条回答 默认 最新

  • dongne1560 2018-06-05 10:18
    关注

    There's a way to "cloak" that for sure.

    The browser takes the information to display from the href attribute... And there is nothing to do to avoid the behavior of displaying it.

    So the trick is to NOT use the href attribute at all. The URL has to be somewhere else then... And a data attribute is perfect for this.

    The markup for the link would be:

    <a class="cloaked" data-href="https://www.example.com/book-launch?utm_source=facebook&utm_medium=social&utm_campaign=book-launch-2014-may">Visit example.com</a>
    

    Then you just have to style the anchor the same way as it would normally look.
    Example CSS:

    .cloaked{
      color:blue;
      text-decoration:underline;
      cursor:pointer;
    }
    

    And finally, a click handler will open a new tab to mimic the normal anchor behavior.

    To open a new tab:

    $(document).ready(function(){
      $(".cloaked").on("click",function(){
        window.open($(this).data("href"));
      });
    });
    

    To open the target page in the current tab:

    $(document).ready(function(){
      $(".cloaked").on("click",function(){
        location.assign($(this).data("href"));
      });
    });
    

    Notice that the UTM params are easilly visible to anyone who knows how to "inspect" a document using the dev tools... And those will be visible in the adress bar of the target page opened.

    评论

报告相同问题?

悬赏问题

  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来