简体   繁体   English

当你 hover 一个超链接时,你如何隐藏 URL?

[英]How do you hide the URL when you hover a hyperlink?

When you hover over a hyperlink you see in the corner of your browser the url you're gonig to.当您通过超链接 hover 时,您会在浏览器的角落看到 url 您正在前往。 I'm using javascript to navigate through my tabs div.我正在使用 javascript 浏览我的标签 div。 When I hover over the tab I see the url.当我在标签上看到 hover 时,我看到了 url。 I would like to hide this.我想隐藏这一点。 Is this possible?这可能吗?

例子

Link to example链接到示例

Don't do it.不要这样做。 Clients like to see where links are going.客户喜欢查看链接的去向。 This behavior isn't up to you.这种行为不取决于你。

The only thing you could reasonably do is set the link to go to nowhere, and set the onclick attribute with sourcecode that does a window.location .您唯一可以合理地做的就是将指向 go 的链接设置为无处,并使用执行window.location的源代码设置onclick属性。

If you don't use the "href" attribute, the link won't show up.如果您不使用“href”属性,链接将不会显示。

Simply do this: <a id="tab1">Tab 1</a>只需这样做: <a id="tab1">Tab 1</a>

$('#tab1').click(function(event) { switchTabs(); });

This will register a click event (using jQuery) on the link without displaying any URL to the user.这将在链接上注册一个单击事件(使用 jQuery),而不向用户显示任何 URL。 This is the proper way for handling links that don't redirect the user.这是处理不重定向用户的链接的正确方法。

<a href="javascript:RedirectToUrl(0)">Hide Text</a>

Then in that function you can have a switch case statement which uses window.location to send the user to another page.然后在 function 中,你可以有一个 switch case 语句,它使用window.location将用户发送到另一个页面。

Downsides to this include alienating your users which disable Javascript, and search engines probably won't follow this link.这样做的缺点包括疏远禁用 Javascript 的用户,并且搜索引擎可能不会关注此链接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM