onclick-event在Firefox中不起作用 - 适用于Internet Explorer

时间:2014-10-08 08:15:11

标签: javascript html internet-explorer firefox dom

我实现了一个名为:remove(this)的onclick事件。它在Internet Explorer中工作正常,但在Firefox中不行。我在remove函数上设置了一个断点,所以我看到IE调用了这个函数而FF没有。 (使用Firebug和IE DeveloperTools调试)

Internet Explorer:

<INPUT onclick="remove( this )" id=NBGTEST-1075_0002__Update__DeleteButton 
title="Remove Spawn" class="update field-button" type=button value=Delete 
name=NBGTEST-1075_0002__Update__SpawnButton>

火狐:

<input id="NBGTEST-1075_0005__Update__DeleteButton" 
class="update field-button" type="button" onclick="remove( this )" 
value="Delete" title="Remove Spawn" name="NBGTEST-1075_0005__Update__SpawnButton">

输入按钮具有相同的参数,只是顺序不同,但这不应该是错误。

这是程序: 按钮A.单击按钮A时,将生成按钮B.按钮B可以删除。函数remove() - 再次删除按钮。 当我按下删除按钮时,按钮会隐藏但该行仍然可见。该行将在remove()函数中删除

按钮代码A(添加按钮):

IE:

<INPUT onclick="add( this )" id=NBGTEST-1075_Main__Update__SpawnButton 
title="Create Spawn" class="update field-button" type=button value="Add Spawn" 
name=NBGTEST-1075_Main__Update__SpawnButton>

FF:

<input id="NBGTEST-1075_Main__Update__SpawnButton" class="update field-button" 
type="button" onclick="add( this )" value="Spawn MR" title="Create Spawn" 
name="NBGTEST-1075_Main__Update__SpawnButton">

两个浏览器都会触发add(this)事件。

我测试了IE11和FF 32.0.3

有趣的事实:当我在Firefox中创建Internet Explorer选项卡时,它也可以运行!

删除功能:

function remove( button )
{
    if( isButton( button ) && isUpdateSection( button.id ) )
    {
         //here I remove the button/row
    }
  return( false );
}

1 个答案:

答案 0 :(得分:0)

我修好了。我只是在removed()中删除了remove()中的函数名。据推测,remove()是一个内部的javascript函数,firefox使用该函数。相反,Internet Explorer检测到我定义了自己的remove()函数。