Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change URL shown in Chrome status bar

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

like image 397
Journeyman Avatar asked Dec 03 '22 02:12

Journeyman


2 Answers

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>
like image 145
KooiInc Avatar answered Dec 18 '22 12:12

KooiInc


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).

like image 42
BoltClock Avatar answered Dec 18 '22 14:12

BoltClock