onclick事件不'不适用于Firefox-适用于Internet Explorer

onclick-event doesn't work in Firefox - works in Internet Explorer

本文关键字:适用于 Firefox- Internet Explorer 不适用 事件 onclick      更新时间:2023-09-26

我实现了一个名为: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>

Firefox:

<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 );
}

我修复了它。我只是在removes()中更改了函数名。据推测,remove()是一个内部javascript函数,firefox使用该函数。相反,InternetExplorer检测到我定义了自己的remove()函数。