当鼠标悬停在网页上的链接上时,如何隐藏浏览器状态栏上的链接?
我在我的项目中使用 Zend、PHP、AJAX、JQuery。问题是,当我将鼠标悬停在网页上的链接上时,如何强制不在浏览器状态栏上显示链接。
最好的例子是在这个网站上,当您将鼠标悬停在该网站上的投票链接上时,它不会显示该链接,并且单击后投票会增加而无需刷新页面。
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
在 Stack Overflow 上,您看不到地址,因为它不是链接(即不是锚点)。它是一个跨度、图像或其他元素,带有 onclick 事件处理程序。
这是保证所有浏览器中都没有状态栏文本的唯一方法,就像设置 window.status = ""; 的老式 JavaScript 方法一样。目前在大多数浏览器中没有效果。
那么,例如...
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...
较旧的浏览器具有类似
window.status = "";
的功能,您可以在其中向状态栏发送消息,并且同样有效地隐藏正常消息。大多数浏览器不再支持此功能。
因此,如果您使用超链接 - 或者更具体地说是锚元素
- 以及
href
属性,则无法绕过状态栏。如果您查看 SO 的 HTML,您会发现投票“链接”根本不是一个链接,而是一个图像,其中包含一些分配给
onclick
事件的 javascript 事件处理程序。那么,为什么当您将鼠标悬停在“投票”上时,光标会变成尖指呢?这是因为 CSS
cursor
属性。该 CSS 来自“all.css”样式表。
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 anhref
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.That CSS comes out of the 'all.css' stylesheet.
仅当您使用带有设置的
href
的元素时,状态栏才会突出显示。
如果您使用纯 JavaScript 打开链接,并且不分配
href
属性,则状态栏中不会显示任何内容。The status bar highlighting happens only when you use an
<a>
element with a sethref
.If you use pure JavaScript to open your link, and don't assign a
href
attribute, nothing will turn up in the status bar.如果您可以看到(查看源代码),侧面的投票链接不是链接,而是图像。如果您单击它,它会在此链接上触发 ajax 函数调用,https://stackoverflow.com/posts/2207467/vote /,更新数据库。
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.
好吧...也许这不是最好的方法,但它有效:
在标签内你可以放置图像或其他东西,你也可以在 onclick 中调用一些函数,然后在它内部调用 AJAX 并在后端有 URL 或进程,我相信是这种情况(一个过程),并不完全导航到另一个页面,因为该新页面在地址栏中会很明显......
希望这有帮助!
Well... maybe it's not the best way but it works:
Inside the tag you can put an image or something else, also you can call some function in the onclick and then inside it call AJAX and have the URL OR process in the backend, which I believe is the case (a process), not exactly navigating to another page, because that new page would be obvious in the address bar...
Hope this helps!