css 隐藏或操纵URL在浏览器左下方当鼠标光标放置在ahref标签

rta7y2nd  于 2023-04-01  发布在  其他
关注(0)|答案(2)|浏览(106)

我想隐藏,删除或操纵URL显示在左下角的浏览器,如谷歌。

尝试使用JS:

<a href="https://example.com" onmouseover="window.status='google.com'; return true;" onmouseout="window.status=''; return true;">Example</a>

尝试使用CSS:

x一个一个一个一个x一个一个二个x

谷歌示例:

在谷歌,当你把指针在任何搜索结果或ahref标签它显示的URL状态像上面的截图,但当你点击它或复制它,你会发现不同的https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=&cad=rja&uact=8&ved=2ahUKEwizyLqk54X-AhWIUGwGHeqDA5EQFnoECCUQAQ&url=https%3A%2F%2Fexample.com%2F&usg=AOvVaw2g9Si57HiLP2X7LeNGKaHd

截图:

wgmfuz8q

wgmfuz8q1#

您可以使用event.preventDefault阻止链接传播,然后使用javascript重定向到另一个页面。
下面是一个简单的例子:

$(document).ready(function (){
   $("a").click(function(event) {
       event.preventDefault(); //stop the redirect
       location.href="https://www.wikipedia.org"; 
   });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="link">
    <a href="http://www.google.it">Google</a>
</div>

希望对您有帮助!

fnx2tebb

fnx2tebb2#

var link = document.getElementById("my-link");
  link.addEventListener("click", function(event) {
    event.preventDefault(); // Prevent the default link behavior
    
    // Change the href to the new URL
    link.href = "https://www.example.net";
    
    // Redirect to the new URL
    window.location.href = link.href;
  });
<a id="my-link" href="https://www.example.com" data-mc-cta="1" target="_blank">Click me!</a>

相关问题