Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i hide the image path on hover using javascript or jquery

Any one who know the answer please give me the suggestion to do this. I am using mozilla firefox browser, When i hover the image i get the url path of where it is located(left bottom of the mozilla) Here is the screenshot: enter image description here

Is it possible to hide the href path. Any suggestion would be great.

like image 997
Vignesh Pichamani Avatar asked Sep 19 '26 18:09

Vignesh Pichamani


2 Answers

Assuming that the status bar shows the href destination, you can remove the href attributes onload and call window.location onclick instead: (jQuery):

$(function() {
    $('a[href]').each(function() {
        var href = this.href;
        $(this).removeAttr('href').css('cursor','pointer').click(function() {
            window.location = href;
        });
    });
});

Note that I added cursor:pointer to make it behave like a link even without the href attribute. The very same technique is often used on mobile web sites to prevent mobile safari to drop down it’s address bar when navigating through ajax.

Another more clumsy way would be to add a placeholder div on top of the anchor that grabs the anchor’s href and navigates using window.location onclick.

Either way, a quick look in the source or in a console would reveal the destination anyway.

like image 67
David Hellsing Avatar answered Sep 22 '26 08:09

David Hellsing


I think if you remove href attribute, and add onClick = "location('your url')" it will hide the href path. for example:

<script>
function changeLocation(url){
   window.location.assign(url);
}
</script>
<a onClick = "changeLocation('http://www.w3schools.com')">Link</a>
like image 23
Алексей Тирон Avatar answered Sep 22 '26 06:09

Алексей Тирон



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!