开发者

How to hide links on browser's statusbar when you mouseover on links on webpage?

I am using Zend, 开发者_Python百科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


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"); });


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜