不同的方法来创建一个空链接? [英] Different methods to make a null link?

查看:146
本文介绍了不同的方法来创建一个空链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在这些方法之外创建一个空链接?

Is there a way to make a null link besides these methods?

<a href="javascript:;">Example</a>

<a href="javascript:void(0);">Example</a>

<a href="#">Example</a>

我不介意让页面跳转到顶端的东西,但我不希望它在地址栏中更改网址。理想的链接应尽可能与维基百科上的导航框中显示的链接类似,但存在因为它有一个相当大的脚本与它相关联,所以比这个链接更重要。我只是想找一些东西放进 a 标签。

I don't mind something that makes the page jump to the top but I don't want it to alter the URL in the address bar. The ideal link would be one as similar as possible to the ones featured on navigation boxes on Wikipedia but there is much more to that link than meets the eye as it has a pretty large script associated with it. I'm just looking for something to put into the a tag.

预先感谢。

推荐答案

您只需要在< a> 标签中插入某些内容? OK:

You just want something you can shove in the <a> tag? OK:

<a href="#" onclick="return false;">Example</a>

将它与任何 href = 方法从你的问题。

Combine it with any of the href= methods from your question.

鉴于一个不会去任何地方的链接是相当无用的,我可以假设你想点击链接时启动一些JavaScript函数?如果是,请执行以下操作:

Given that a link that doesn't go anywhere is fairly useless, can I assume you want to kick off some JavaScript function when the link is clicked? If so, do this:

<a href="#" onclick="yourFunctionHere(); return false;">Example</a>

这篇关于不同的方法来创建一个空链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆