锚标签中的javascript [英] javascript in anchor tags

查看:66
本文介绍了锚标签中的javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果使用onclick事件处理程序在单击锚点

元素时执行javascript,那么href属性应该是什么? #?

javascript :void(0)?还有别的吗?

If using an onclick event handler to execute javascript when an anchor
element is clicked on, what should the href attribute be? #?
javascript:void(0)? Something else?

推荐答案

yawnmoth于2005年5月5日在comp.lang.javascript上写道
yawnmoth wrote on 05 sep 2005 in comp.lang.javascript:
如果使用onclick事件处理程序在单击锚点
元素时执行javascript,那么href属性应该是什么? #?
javascript :void(0)?还有什么?
If using an onclick event handler to execute javascript when an anchor
element is clicked on, what should the href attribute be? #?
javascript:void(0)? Something else?




为没有活动js的访问者提供默认页面

并在js中给出一个返回false:


< a href =''/ mySorries / sorryNoJS.html''onclick =''doMyClick(); return false;''>

无论如何请点击我< / a>


-

Evertjan。

荷兰。

(替换所有十字架我的电子邮件中的点)



Provide a default page for visitors without active js
and give a return false in js:

<a href=''/mySorries/sorryNoJS.html'' onclick=''doMyClick();return false;''>
Please click me anyway</a>

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


" yawnmoth"写了
"yawnmoth" wrote
如果使用onclick事件处理程序在单击一个锚
元素时执行javascript,那么href属性应该是什么? #?
javascript :void(0)?还有什么?
If using an onclick event handler to execute javascript when an anchor
element is clicked on, what should the href attribute be? #?
javascript:void(0)? Something else?



普通网页的普通网址,其中包含访问者的替代内容

没有Javascript。通过从事件处理程序返回false,那些具有

Javascript的人永远不会知道或关心href值。还有机器人可以按照这个链接获得
,而他们在访问Javascripted

内容时遇到一些问题。

如果您还没有,请检查新闻组常见问题,特别是

< URL: http://www.jibbering.com/faq/#FAQ4_24 >


hth

ivo


A normal URL of a normal page, with alternative content for the visitors
without Javascript. By returning false from the event handler, those with
Javascript will never know or care about the href value. Also bots can
follow that link, while they have some problem accessing Javascripted
content.
In case you haven''t already, check the newsgroup FAQ as well, especially
<URL: http://www.jibbering.com/faq/#FAQ4_24 >

hth
ivo


*** Evertjan。写道/escribió(2005年9月5日09:11:07 GMT):
*** Evertjan. wrote/escribió (05 Sep 2005 09:11:07 GMT):
为没有活动js的访问者提供默认页面
并在js中返回false:

< a href =''/ mySorries / sorryNoJS.html''onclick =''doMyClick(); return false;''>
无论如何请点击我< / a>
Provide a default page for visitors without active js
and give a return false in js:

<a href=''/mySorries/sorryNoJS.html'' onclick=''doMyClick();return false;''>
Please click me anyway</a>



使用''#'特别烦人。它迫使你的浏览器滚动到顶部

页。

-

- álvaroG。Vicario - 西班牙布尔戈斯
- http://bits.demogracia.com - Mi sitio sobre programaciónweb

- 不要给我发电子邮件,把它们发给小组

-


Using ''#'' is particularly annoying. It forces your browser to scroll to top
of page.
--
-- álvaro G. Vicario - Burgos, Spain
-- http://bits.demogracia.com - Mi sitio sobre programación web
-- Don''t e-mail me your questions, post them to the group
--


这篇关于锚标签中的javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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