How Can I Hide The Image Path On Hover Using Javascript Or Jquery
Solution 1:
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.
Solution 2:
I think if you remove href attribute, and add onClick = "location('your url')" it will hide the href path. for example:
<script>functionchangeLocation(url){
window.location.assign(url);
}
</script><aonClick = "changeLocation('http://www.w3schools.com')">Link</a>
Solution 3:
You can do it by calling on click method that opens image url in browser (url stored in data-href
instead of href
):
http://jsfiddle.net/mattydsw/TYSnB/
<a data-href="http://somewhere.com">new</a>
$('a[data-href]').on('click', function(e) {
e.preventDefault();
window.location.href = $(this).data('href');
});
EDIT
But also whole rest of "standard" behavior will be lost, e.g. open in new tab, copy link, search engines crawling.
Solution 4:
I see that you have got already one answer for that, but if you want to open in new popup/window on click then it's fine but if you want to open in same page then what happen? also if you have use master page and on click of link like this new page load on content place holder area than what happen?
I have one of solution if you like.
We can use system.webrouting.routecollection in global.asax page for hide all or any page, See below example:
voidApplication_Start(object sender, EventArgs e)
{
RegisterRoutes(System.Web.Routing.RouteTable.Routes);
}
voidRegisterRoutes(System.Web.Routing.RouteCollection routes)
{
routes.Clear();
routes.MapPageRoute("page1", "dir1/{country}/{State}", "~/page1.aspx");
}
It would be helpful to you.
Solution 5:
<aonclick="window.open('http://whatever', '_self');"><imgblablabla ></a>
EDIT : Note that it maybe not be great for referencing as this is not a natural way to do a link, robots won't crawl through it.
Post a Comment for "How Can I Hide The Image Path On Hover Using Javascript Or Jquery"