开发者

how to change link url on the web browser's status bar

I already read many article about this issue in here, SO.

I just want to discuss how to do it. NOT the moral issue.

--

for example.

at the google search webpage.

before I click the link, the link does not indicate the google url.

but After I click the link w开发者_C百科ith shift-key, the url on the status bar is changed.

this mean the google webpage indicate 'Fake URL'.

the google compressed script is too difficult to read and analyze.

#

edited

The second url should work on ie8 even if I click with ctrl key.


The browser always shows link's href-attribute (no way to fake this), but you can capture the click event for link and do whatever you want. An example using jQuery:

$('a').each(function() {
    $(this)
        .attr('orig_href', $(this).attr('href'))
        .attr('href', 'http://google.com');
}).click(function(e) {
    e.preventDefault();
    window.location.href = $(this).attr('orig_href');
});


<a href="http://this-url-will-be-shown/" onclick="location.href='http://this-url-will-be-opened/'; return false;">Click me</a>


You use javascript to change the status in the window:

window.status='Your Message Here';

You would attach this to some event (onmouseover)

For example:

<A HREF="http://www.stackoverflow.com" onMouseOver="window.status='http://www.google.com'; return true"></A>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜