How to hide links on browser's statusbar when

2019-01-25 23:10发布

I am using Zend, PHP, AJAX, JQuery in my projects. Question is that how can I force to not display a link on browser's statusbar when I mouseover on a link on my webpage.

Best example is on this site, when you mouseover the up-vote link on this site, it does not show the link and after click the votes increased without refreshing the page.

Thanks

4条回答
来,给爷笑一个
2楼-- · 2019-01-25 23:29

On Stack Overflow, you don't see an address, because it isn't a link (i.e. it isn't an anchor). It is a span, image or other element, with an onclick event handler.

This is the only way to guarantee no status-bar text in all browsers as the old-school JavaScript method of setting window.status = ""; has no effect in most browsers these days.

So, for example...

[Html]
<img id="clickme" src="myimage.png" alt="My Image" title="Vote">

[JavaScript (jQuery)]
$("#clickme").click(function() { alert("You clicked me"); });
查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-01-25 23:29

Older browsers had something like window.status = ""; where you could send messages to the status bar, and likewise effectively hide normal messages.

This is no longer supported on most browsers.

So, if you use a hyperlink - or more specifically an anchor element <a> - with an href attribute, there's no getting around the status bar.

If you check out the HTML for SO, you'll see the vote up "link" isn't a link at all but an image with some javascript event handlers assigned to the onclick event.

So why is that the cursor turns into that pointed finger when you mouse over the "vote up"? That's because of the CSS cursor property.

.vote img {
    cursor:pointer;
}

That CSS comes out of the 'all.css' stylesheet.

查看更多
虎瘦雄心在
4楼-- · 2019-01-25 23:32

The status bar highlighting happens only when you use an <a> element with a set href.

If you use pure JavaScript to open your link, and don't assign a href attribute, nothing will turn up in the status bar.

查看更多
我命由我不由天
5楼-- · 2019-01-25 23:43

if you can see (view source ), the vote up link on the side is not a link, it is an image. If you click on it, it fires an ajax function call on this link, https://stackoverflow.com/posts/2207467/vote/, which updates the database.

查看更多
登录 后发表回答