适当的空链接方式 [英] proper ways for empty link

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

问题描述

如果我想要一个空链接,哪种方式更合适?


< a href ="">

< ; a href ="#">

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


Xah
xa*@xahlee.org

a ?? http://xahlee.org/

if i want to have a empty link, which way is more proper?

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

Xah
xa*@xahlee.org
a?? http://xahlee.org/

推荐答案

Xah Lee写道:
Xah Lee wrote:
如果我想要一个空链接,哪种方式更合适?
< a href ="">
< a href ="#">
< a href =" javascript :void( 0);">
if i want to have a empty link, which way is more proper?

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




怎么样< a> ?

这不是一个真正的链接,但话又说回来,我不知道为什么会有一个人需要一个空的链接...

你能详细说明你实际想要实现的目标吗?


-

Els http://locusmeus.com/

Sonhos vem。 Sonhos v?£。 O resto ?? crisfeito。

- Renato Russo -



How about <a> ?
It''s not a link really, but then again, I have no idea why one would
need an empty link...
Can you elaborate on what you are actually trying to achieve?

--
Els http://locusmeus.com/
Sonhos vem. Sonhos v?£o. O resto ?? imperfeito.
- Renato Russo -


" Xah Lee" < xa*@xahlee.org>写道:
"Xah Lee" <xa*@xahlee.org> wrote:
如果我想要一个空链接,哪种方式更合适?


为什么你想要一个空的链接?

< a href ="">


这是对文档本身的引用。

< a href ="#">


这是对当前文档开头的引用。

< a href =" javascript :void( 0);">
if i want to have a empty link, which way is more proper?
Why would you want to have an empty link?
<a href="">
This is a reference to the document itself.
<a href="#">
This is a reference to the start of the current document.
<a href="javascript:void(0);">




这是未定义的; javascript :网址未注册。


您也可以创建自引用链接:

< a name =" ; foo42" href =" #foo42">


我想你想要一个空的链接,这样你就可以制作一些东西

可点击,触发一些脚本事件,而不是链接。

简单的答案是:不要。


将它指向一个包含有用替换的地址的链接

的功能,如果相关的话。


< a href =" #nojs"的onclick = QUOT; FOO();返回false">

.. 。

< h2 id =" nojs"> Something< / h2>

< p>放在这里有用的东西。< / p>


如果您的HTML代码已使用JavaScript _generated_,那么如果JavaScript关闭则不会出现

元素,请使用href ="#"但请确保您的

事件处理程序返回false,以便永远不会使用href(如果它导致文件开头的移动,则可能是
有害) 。


-

Yucca, http://www.cs.tut.fi/~jkorpela/

有关网页制作的网页: http://www.cs.tut.fi/~jkorpela/www.html



This is undefined; javascript: URLs are unregistered.

You could create a self-referencing link, too:
<a name="foo42" href="#foo42">

I suppose you want to have an "empty" link so that you can make something
clickable, triggering some scripted events, without making it a link.
The simple answer is: don''t.

Make it a link that points to an address that contains a useful replacement
for the functionality, if it is relevant.

<a href="#nojs" onclick="foo(); return false">
.. . .
<h2 id="nojs">Something</h2>
<p>Put here something useful.</p>

If your piece of HTML code has been _generated_ with JavaScript, so that the
element does not appear if JavaScript is off, use href="#" but make sure your
event handler returns false, so that the href will never be used (it could be
harmful if it caused a movement to the start of the document).

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html




Xah Lee写道:

Xah Lee wrote:
如果我想要一个空链接,哪种方式更合适?

< a href ="">
< a href ="#">
< a href =" javascript :无效(0);">


你可能想在这个问题上阅读这个广泛的(而且是密集的)讨论



< http ://groups.google.com/group/comp.lang.javascript/browse_frm/thread/4d2e99b2a8bdbbd2/b595a7a81b0a62a3>

来自我个人留下的*列出的*选项:
if i want to have a empty link, which way is more proper?

<a href="">
<a href="#">
<a href="javascript:void(0);">
You may want to read this extensive (and rather intensive) discussion
on this very question here:
<http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/4d2e99b2a8bdbbd2/b595a7a81b0a62a3>
From the *listed* options I personally would stay with:



< a href =" javascript :void(myFunction())">


< a href = "">和< a href ="#">如果页面

在旧浏览器上足够长,将导致翻页/滚动。


<a href="javascript:void(myFunction())">

<a href=""> and <a href="#"> will lead to page shift/scroll if the page
is long enough on older browsers.


这篇关于适当的空链接方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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