简体   繁体   English

如何在使用href = javascript时保持url显示:blah()

[英]how to keep the url from displaying when using a href=javascript:blah()

Don't know if this is easy or not (as I'm not well versed in javascript and/or html), but I'm trying to keep the url (in this case it's a function) from showing whenever there's a mouseover. 不知道这是否容易(因为我不熟悉javascript和/或html),但是我试图保持url(在这种情况下它是一个函数),只要有鼠标悬停就显示出来。 I've done it in HTML, but haven't using javascript.. my simple code is below... 我已经用HTML完成了,但没有使用javascript ..我的简单代码如下...

<a href="javascript:CloseAndOpen(1);">Click Here</a>

I don't want the a href to appear. 我不希望出现一个href。

Any help would be greatly appreciated! 任何帮助将不胜感激!

根本不要在“href”值中使用JavaScript。

<a href=# onclick='CloseAndOpen(1)'>Click Here</a>

A link is supposed to show where it goes. 链接应该显示它的去向。 If you don't want to show the address, don't use a link, just a regular element with a click event: 如果您不想显示地址,请不要使用链接,只使用带有click事件的常规元素:

<span onclick="CloseAndOpen(1);">Click here</span>

You can use CSS to style it so that it looks like a link if you like. 你可以使用CSS来设置它的样式,以便它看起来像一个链接,如果你愿意。

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

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