Vignesh Pichamani
Vignesh Pichamani

Reputation: 8070

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.

Upvotes: 3

Views: 3789

Answers (5)

David Hellsing
David Hellsing

Reputation: 108500

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.

Upvotes: 1

Himanshu kamothi
Himanshu kamothi

Reputation: 40

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:

void Application_Start(object sender, EventArgs e)
    {      
        RegisterRoutes(System.Web.Routing.RouteTable.Routes);
    }

void RegisterRoutes(System.Web.Routing.RouteCollection routes)
    {
        routes.Clear();
        routes.MapPageRoute("page1", "dir1/{country}/{State}", "~/page1.aspx");
}

It would be helpful to you.

Upvotes: 0

mkutyba
mkutyba

Reputation: 1427

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.

Upvotes: 0

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>

Upvotes: 1

Virus721
Virus721

Reputation: 8335

<a onclick="window.open('http://whatever', '_self');"><img bla bla bla ></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.

Upvotes: -1

Related Questions