skip to Main Content

I want to hide, remove or manipulate URL display in left-bottom in browser like Google.

Trying with JS:

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

Trying with CSS :

.no-tooltip:hover::after {
  content: none !important;
}
<a href="http://example.com" class="no-tooltip">Link</a>

Google example :

enter image description here

In Google, when you place pointer in any search result or ahref tag it show URL Status like above screenshot but when you click it or copy it you will find different 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

Screenshot :

enter image description here

2

Answers


  1. You can use event.preventDefault to block link propagation and then redirect to another page with javascript.

    Here’s a simple example:

    $(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>

    Hope i was helpful!

    Login or Signup to reply.
  2. You cannot change Window.status. To achive desire result, you can use location.href or location.replace

      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.com";
        
        // Redirect to the new URL
        //window.location.href = link.href;
        window.location.replace(link.href);
      });
    <a id="my-link" href="https://www.google.com" data-mc-cta="1" target="_blank">Click me!</a>

    To include left-clicks, right-clicks and contextmenu

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

    For multiple URL using class & for-loop

    var links = document.getElementsByClassName("link");
    
    function redirectLink(event) {
      event.preventDefault(); // Prevent the default link behavior
      this.href = "https://example.com"; // Change the href to the new URL
      window.location.replace(this.href); // Redirect to the new URL
    }
    
    // Loop through all links with the afflink class and add event listeners
    for (var i = 0; i < links.length; i++) {
      links[i].addEventListener("click", redirectLink);
      links[i].addEventListener("contextmenu", redirectLink);
    }
    <a href="https://www.google.com" class="link"> Google </a>
    <a href="https://www.yahoo.com" class="link"> Yahoo </a>
    <a href="https://www.bing.com" class="link"> Bing </a>

    Only Right click to all a href with respective URL

    var links = document.getElementsByTagName("a");
     for (var i = 0; i < links.length; i++) {
       links[i].addEventListener("contextmenu", function(event) {
         event.preventDefault();
         window.location.replace(this.href);
       });
     }
    <a href="https://www.Example.com"> Example </a>
    <a href="https://www.wikipedia.com"> Wikipedia </a>
    <a href="https://www.bing.com"> Bing </a>
    <a href="https://www.stackoverflow.com"> stackoverflow </a>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search