4

When I hover over a url in Chrome, the url is displayed in the Chrome status bar. In my case this results in an ugly javascript:bla-bla-bla reference. Is there any way to change the contents of the status bar when you hover over a link?

Thanks

6 Answers 6

10

Although you selected your answer, this idea is an alternative.

You can change the href attribute on mouseover to affect what the status bar says, and change it back on mouseout or click:

function showNiceLink(el, e) {
  e = e || event;
  el.originalHref = el.originalHref || el.href;
  console.log(e.type);

  if (/click|out/i.test(e.type)){
    el.href = el.originalHref;
  } else {
    el.href = "http://Linking...";
  }
}
<a href="#this is a really UGLY link @1##$$%!!&"
   onmouseover="showNiceLink(this,event)"
   onmouseout="showNiceLink(this,event)"
   onclick="showNiceLink(this,event)">a link with an ugly <code>href</code></a>

7

I'm pretty sure for security reasons this isn't possible in any browser. Otherwise links to phishing sites will become much, much harder to detect, because attackers can then just place a genuine URL in the status bar while the dangerous link actually leads elsewhere...

Use an onclick event handler for your hyperlink instead, and put a real, meaningful URL in the href attribute in place of the javascript: link (even if the link is meant to be used only with JavaScript).

4
  • I'm developing this to run 'full-screen' in an iPad. This means that I want to keep using the href="javascript..." format because it is the only one that doesn't 'jump out' of full screen mode.
    – Journeyman
    Jun 18, 2011 at 7:45
  • @Journeyman: Well in that case I think iOS web app should stay an iOS web app. I'd prefer to serve a different kind of frontend to desktop browsers, with normal hyperlinks instead of the Ajax links that Mobile Safari requires for web apps.
    – BoltClock
    Jun 18, 2011 at 8:25
  • 1
    Doesn't this mean that phishing sites can just add legitimate links and replace their onclick event to lead to a malicious URL? Sep 16, 2013 at 14:08
  • @Timo Huovinen: Now that you mention it, yes, they can. I recall seeing a proof of concept demonstrating it somewhere but I can't remember the URL.
    – BoltClock
    Sep 16, 2013 at 14:39
1
<a href="#" onClick="yourFunc(); return false;">Your "link"</a>
0

I guess you mean you want to change what destination is shown for link that is selected? In that case you most likely should put nice url in href attribute, and use onclick attribute for your javascript. Not sure that you can duplicate everything what is done by putting javascritp in href.

0

Assuming this is what you have:
<a onClick="blabla">Link</a>
Add href="#" to it. Then the # should be shown in stead of the javascript:blabla.
So that would be like this:
<a href="#" onClick="blabla">Link</a>

2
  • Do not use javascript: in an intrinsic event handler, it will be interpreted as a (useless) label.
    – RobG
    Jun 18, 2011 at 7:29
  • Oh right, I forgot you don't need to add javascript: in the onClick event.
    – RobinJ
    Jun 18, 2011 at 7:31
0

It is definitely possible to achieve the desired effect. Just look at what Google puts in the status bar of its search results.

However, you need to use some kind of a trick, e.g. onclick like BoltClock suggested.

Google shows you what you would like to see - a plain, clean URL. Underneath, however, they use a long redirect URL with monitoring parameters to track you down as you click any result link. That way Google monitors which of the search results are clicked on and which are not.

Unfortunately, most people do not realize that. Quite frankly, I would be very glad to see a browser extension which takes all this dirty tricks down and replaces "tracking" URLs with the "real ones".

3
  • My google chrome status bar shows the full real link when I hover over a google search result, is that not what you want the plugin to achieve? Sep 16, 2013 at 14:11
  • Yes, that is exactly the thing I was talking about. I am not sure how it works in Chrome, but Firefox shows just the dummy links (i.e. destinations to where you will be redirected after your click is tracked by Google). Nov 29, 2015 at 23:12
  • A browser extension for replacing Google's tracking URLs to search results with the real ones indeed exists: github.com/palant/searchlinkfix Jul 3, 2018 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.