[英]Javascript function is not working in IE browser
i am working on javascript onclick event, when i call function on button click it not gets works on IE browsers (IE-9 & IE-8) 我正在处理javascript onclick事件,当我在按钮上调用函数时,单击它无法在IE浏览器(IE-9和IE-8)上正常工作
code as following 代码如下
<input type='image' src="mybutton.jpeg" name="submit" id="button" onclick="return myfunction();" />
i have defined function at top of my page, 我在页面顶部定义了功能,
<script type="text/javascript">
function myfunction()
{
alert("This is testing");
}
</script>
Working on all other browsers like chrome & firefox but not in IE. 可在所有其他浏览器(如chrome和firefox)上使用,但不能在IE中使用。
Please help me on this. 请帮我。
Change your onclick from: 从以下位置更改onclick:
onclick="return myfunction();"
to 至
onsubmit="return myfunction();"
I don't like putting "listener" attributes. 我不喜欢放置“侦听器”属性。 This works for me:
这对我有用:
HTML: HTML:
<input type='image' src="" name="submit" id="button" />
JS: JS:
function myfunction() {
alert("This is testing");
}
document.getElementById('button').addEventListener('click', function() {
return myfunction()
} , false);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.