How do they hide URL when mouseover?

2019-07-24 01:11发布

问题:

Everybody knows that the good old school windows.status is not working anymore when mouseover a link. However, I found a site which seems to be blanking out the URL link while the link is always below the mouse.

More details below: Answered

回答1:

Google AdSense uses an onclick JavaScript event handler to redirect the user in this case, not the href attribute of a link. Here is the (approximate) source code of the element (several iframes deep) that traps the user's mouse click. According to Firebug, the user's mouse click goes to the outer td element.

<td valign="middle" align="center" onclick="ga(this,event)" onmouseout="cs()" onmouseover="return ss('go to www.Solar-Aid.org','aw0')" onmousedown="st('aw0')" onfocus="ss('go to www.Solar-Aid.org','aw0')" class="ch" id="taw0">
  <div style="overflow: hidden; word-wrap: break-word; width: 116px;">
    <font face="impact, poster bodoni, geneva" style="font-size: 20px;">
      <a style="text-decoration: none;" class="textcolor" onmouseout="cs()" onmouseover="return ss('go to www.Solar-Aid.org','aw0')" onmousedown="st('aw0')" onclick="ha('aw0')" onfocus="ss('go to www.Solar-Aid.org','aw0')" href="http://googleads.g.doubleclick.net/pagead/iclk?sa=l&amp;ai=BBuZpfBTrTMqHJ8zLsQfDsviMDfKumAKzyl3SmZ0CABABGAEgACgEOACCAQZjYS1wdWKIAQGQAfDkArIBDXNvbGFyLWFpZC5vcme6AQoxMjB4NjAwX2FzwAEC2gEZaHR0cDovL3d3dy5Tb2xhci1BaWQub3JnL8gDFw&amp;num=1&amp;adurl=http://www.Solar-Aid.org/&amp;client=ca-pub-0563973986972825&amp;nm=34" target="_top" id="aw0">
        Solar Energy Charity
      </a>
    </font>
    <br><br><br>
    <!-- snip -->
  </div>
</td>

The actual text links are irrelevant; they are farther down than the height of the spammer's mouse-following iframe (which has a set opacity of 0.1, so it remains nearly invisible to the user). ga is just a function that changes the outside window's URL using top.location.href:

function ga(o, e) {
  if(document.getElementById) {
    a = o.id.substring(1);
    // snip
    top.location.href = document.getElementById(a).href;
  }
}

By the way, there's no need to worry about the spammer making money when you click on that particular ad because it is a public service ad (PSA). Clicks on PSAs do not earn any money for a publisher, and Google can show PSAs for several reasons including that the AdSense account has not been approved.



回答2:

Perhaps I'm unclear on what you're trying to do (since the example link is gone), but does this seem right?

HTML:

<a href="">Link</a>

jQuery:

$("a").click(function() {
location.href="www.yahoo.com";
return false;
});