javascript - IE 没有在 onblur 事件中调用函数

标签 javascript php html c internet-explorer

事情是这样的:我已经删除了 JavaScript 函数的内容进行测试,现在它看起来像这样:

function media(id) {
    alert('IT WORKS!');
}

我在两个不同的事件中调用此函数。第一个是“onload”事件,第二个是“onblur”事件:

<body onload="media()">

<!-- irrelevant part of the code -->

<input type="text" readonly onBlur="if (teto(this, 100, 1)) { salva_campo('EDICAO[ALUNO_DISC][1][NOTA][0][DADOS][VALOR]', 'SALVA_NOTA', '43782', '5045', this.value); media(1); } " name="EDICAO[ALUNO_DISC][1][NOTA][0][DADOS][VALOR]" id="EDICAO[ALUNO_DISC][1][NOTA][0][DADOS][VALOR]" size="5" value="" tabindex="2" maxlength="5" onkeypress="if (event.keyCode == 13) muda_campo(1, 0);">

该代码在 Chrome 和 Firefox 中就像一个魅力,但在 IE 中,函数 media() 只是由 onload 事件调用。我认为这个问题与 onblur 事件无关,因为函数 salva_campo() 工作得很好。对正在发生的事情有什么想法吗?

最佳答案

模糊事件确实在 Internet Explorer 中触发,您可以 view the following simple test on JSFiddle :

<input type="text" readonly onBlur="alert('blur');">

这意味着错误可能出现在您正在运行的脚本中。您尚未提供所有代码,因此无法对其进行测试,但如果您在 Internet Explorer 中按 F12 并查看“控制台”选项卡,您应该会收到更具描述性的错误,您可以向我们询问该错误。

关于javascript - IE 没有在 onblur 事件中调用函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25766512/

相关文章:

javascript - 使用 toFixed() 删除矩阵所有元素的多余数字

javascript - 注册成功后在 "userCategory"下创建新的 "User"对象

php - html php通过多个页面和内部表单传递变量

php - Laravel 6 中打包 tymondesigns/jwt-auth 安装问题

php - 如何从 MySQL 数据库中检索图像并显示在 html 标签中

jquery - Packery js 洗牌并适合容器

javascript - 在 Visual Studio 中编辑 HTML 文件时支持 Javascript 模板标记

javascript - 带有显示内联 block 或向左浮动的 jquery 垂直 slider

php - 在 'order(` pcode 附近获取错误检查你的 mysql 语法`)

html - 使用 CSS 扩展 div 而没有 Javascript