onclick事件在IE7中不起作用 [英] onclick event not working in IE7

查看:104
本文介绍了onclick事件在IE7中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


在我的网站上,我有一个< selectdrop-down菜单,允许显示/

隐藏div: http://tchernobyl.dreamhosters.com - 问题在于它

在IE7中不起作用(仅在Opera和Firefox中测试过)。但是,如果我在< atag中包含onclick事件,它在IE中工作正常(但在< optiontags中不是

)。在下拉菜单旁边,我放了一个测试按钮。链接

在IE7中工作正常。你知道原因可能是什么吗?这是

片段:


//作品:


< select>

< option onclick =" showdiv(''bataille'')"> La Bataille de Tchernobyl< /

选项>

<选项onclick =" showdiv(''soleil'')"> Soleil< / option>

< option onclick =" showdiv(''catastrophe'')"> La灾难de

Tchernobyl< / option>

< option onclick =" showdiv(''vingt_ans'')"> Tchernobyl,Vingt Ans
$ b $bAprès< / option>

< / select>


//无法工作:


< a href ="#" onclick =" showdiv(''soleil'')"> test< / a>


提前致谢,


Charles 。

解决方案

谢谢你们。我使用< selectelement

建议解决问题。


查尔斯。


Charles写道:


您好,


在我的网站上,我有一个< selectdrop-down菜单允许显示/

隐藏div: http://tchernobyl.dreamhosters。 com - 问题是它在IE7中无法工作(仅在Opera和Firefox中测试过)。但是,如果我在< atag中包含onclick事件,它在IE中工作正常(但在< optiontags中不是

)。在下拉菜单旁边,我放了一个测试按钮。链接

在IE7中工作正常。你知道原因可能是什么吗?这是

片段:


//作品:


< select>

< option onclick =" showdiv(''bataille'')"> La Bataille de Tchernobyl< /

选项>

<选项onclick =" showdiv(''soleil'')"> Soleil< / option>

< option onclick =" showdiv(''catastrophe'')"> La灾难de

Tchernobyl< / option>

< option onclick =" showdiv(''vingt_ans'')"> Tchernobyl,Vingt Ans
$ b $bAprès< / option>

< / select>


//无法工作:


< a href ="#" onclick =" showdiv(''soleil'')"> test< / a>


提前致谢,


Charles 。



将onclick =调用放在< selectstatement中。这样可行。它是一个

IE6 / 7功能IIRC。


10月7日下午12:44,Charles< landema .. 。@ gmail.comwrote:


谢谢大家。我使用< selectelement

建议修复了这个问题。


查尔斯。



在我看来,更改事件比点击事件更合适且可以访问



Hello,

On my web site, I have a <selectdrop-down menu that allows to show/
hide divs: http://tchernobyl.dreamhosters.com - The problem is that it
doesn''t work in IE7 (only tested in Opera and Firefox). However, if I
include the onclick event in an <atag, it works fine in IE (but not
within <optiontags). Next to the drop-down menu, I put a "test" link
which works fine in IE7. Do you know what may be the cause? Here''s the
snippet:

// Works:

<select>
<option onclick="showdiv(''bataille'')">La Bataille de Tchernobyl</
option>
<option onclick="showdiv(''soleil'')">Soleil</option>
<option onclick="showdiv(''catastrophe'')">La Catastrophe de
Tchernobyl</option>
<option onclick="showdiv(''vingt_ans'')">Tchernobyl, Vingt Ans
Après</option>
</select>

// Doesn''t work:

<a href="#" onclick="showdiv(''soleil'')">test</a>

Thanks in advance,

Charles.

解决方案

Thanks guys. I fixed the problem using the <selectelement as
suggested.

Charles.


Charles wrote:

Hello,

On my web site, I have a <selectdrop-down menu that allows to show/
hide divs: http://tchernobyl.dreamhosters.com - The problem is that it
doesn''t work in IE7 (only tested in Opera and Firefox). However, if I
include the onclick event in an <atag, it works fine in IE (but not
within <optiontags). Next to the drop-down menu, I put a "test" link
which works fine in IE7. Do you know what may be the cause? Here''s the
snippet:

// Works:

<select>
<option onclick="showdiv(''bataille'')">La Bataille de Tchernobyl</
option>
<option onclick="showdiv(''soleil'')">Soleil</option>
<option onclick="showdiv(''catastrophe'')">La Catastrophe de
Tchernobyl</option>
<option onclick="showdiv(''vingt_ans'')">Tchernobyl, Vingt Ans
Après</option>
</select>

// Doesn''t work:

<a href="#" onclick="showdiv(''soleil'')">test</a>

Thanks in advance,

Charles.

Put the onclick= call in the <selectstatement. That works. Its an
IE6/7 feature IIRC.


On Oct 7, 12:44 pm, Charles <landema...@gmail.comwrote:

Thanks guys. I fixed the problem using the <selectelement as
suggested.

Charles.

Seems to me that the change event would be more appropriate and
accessible than the click event.


这篇关于onclick事件在IE7中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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