void(0)禁用我的onclick事件(即只)? [英] void(0) is disabling my onclick event (ie only) ???

查看:89
本文介绍了void(0)禁用我的onclick事件(即只)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

onclick =" window.location.href =''/ foo.bar ?one = false& two = true''">链接< / a>


就像Firefox中的魅力一样。我在IE中没有。但如果我只用#替换了javascript :void(0)的

,那么它适用于IE。跆拳道?任何

帮助。

<a href="javascript: void(0);"
onclick="window.location.href=''/foo.bar?one=false&two=true''">Link</a>

works like a charm in Firefox. I get NOTHING in IE. but if I replace
the javascript: void(0) with just a #, then it works in IE. wtf? Any
help.

推荐答案

< se ********** @ gmail.com>在消息中写道

news:11 ********************** @ g49g2000cwa.googlegr oups.com ...
<se**********@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
< a href =" javascript :void(0);"
onclick =" window.location.href =''/ foo.bar?one = false& two = true''"> Link< / a>

就像Firefox中的魅力一样。我在IE中没有。但如果我只用#替换javascript :void(0),那么它在IE中有效。跆拳道?任何
帮助。
<a href="javascript: void(0);"
onclick="window.location.href=''/foo.bar?one=false&two=true''">Link</a>

works like a charm in Firefox. I get NOTHING in IE. but if I replace
the javascript: void(0) with just a #, then it works in IE. wtf? Any
help.




难道你的行为与以下相同吗?


< a href =" /foo.bar?one = false& two = true"> Link< / a>

或者这些链接可能会有所帮助:

所以,当你想在锚标签上放置onclick处理程序时,......
http://www.themaninblue.com/writing/...ve/2004/08/05/


锚和链接

"如果为ONCLICK属性提供值,

指定的操作将覆盖默认链接行为。"
http:// devedge-temp .mozilla.org / libr ... ide / tags7.html

Javascript最佳实践

使用onClick in< A>标签
http://www.mattkruse.com/javascript/bestpractices/



Isn''t what you''re doing the same as the following?

<a href="/foo.bar?one=false&two=true">Link</a>
Or maybe these links will help:

"So, when you want to place an onclick handler on an anchor tag, ..."
http://www.themaninblue.com/writing/...ve/2004/08/05/

Anchors and Links
"If you supply a value for the ONCLICK attribute,
the specified action overrides the default link behavior."
http://devedge-temp.mozilla.org/libr...ide/tags7.html

Javascript Best Practices
Using onClick in <A> tags
http://www.mattkruse.com/javascript/bestpractices/


是的,它与将url放在href属性中相同,但是

我不想要机器人按照链接,所以我有javascript执行

重定向。我很欣赏你提到的链接,但没有一个

解释我所看到的行为。我对其他

技术并不是那么感兴趣,而是我有兴趣理解为什么我写的代码我没有在IE中运行。

yes, it is the same as just putting the url in the href attribute, but
I don;t want bots to follow the link, so I am having javascript perform
the redirect. I appreciate the links you mention but none of them
explain the behavior I am seeing. I''m not so much interested in other
techniques, instead I am interested in understanding why the code I
have written doesn''t function in IE.


se ******** **@gmail.com 写道:
se**********@gmail.com wrote:
是的,它只是将url放在href属性中,但
我不想要机器人按照链接,所以我有javascript执行
重定向。
yes, it is the same as just putting the url in the href attribute, but
I don;t want bots to follow the link, so I am having javascript perform
the redirect.




不是一个好主意......


1 - 并非用户代理组中的每个成员都不是机器人支持

JavaScript


2 - 并非每个用户代理组成员都不支持

JavaScript已启用JavaScript


和biggy ...


3 - 并非用户代理组bots中的每个成员不支持

JavaScript。


我有一个很棒的小机器人(Pavuk)支持JavaScript。


只需使用robots.txt就可以让机器人远离这些网址。


-

David Dorward< http:// blog。 dorward.me.uk/> < http://dorward.me.uk/>

首页是〜/ .bashrc的位置



Not a great idea ...

1 - Not every member of the group of user agents "not bots" supports
JavaScript

2 - Not every member of the group of user agents "not bots that support
JavaScript" has JavaScript turned on

and the biggy ...

3 - Not every member of the group of user agents "bots" does not support
JavaScript.

I''ve got a nice little bot (Pavuk) which supports JavaScript.

Just use robots.txt to ask bots to keep away from those URLs.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is


这篇关于void(0)禁用我的onclick事件(即只)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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