本文介绍了JavaScript的event.target在Mozilla工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<script type ='javascript'>
function fun(userID) {
var btn = event.target; // error 'event' undefine in mozilla
alert(btn.id);
}
</script>
<asp:linkButton id ="target" style =" cursor:pointer" onclick ="fun('1')" >click here </asp:LinkButton>
我在JavaScript的新的,我已经写了超过code和这code是工作的罚款谷歌浏览器,但在Mozilla Firefox中不工作。任何人都可以提出如何找到射击控制事件?
I am new in JavaScript, I have written above code and this code is working fine in Google chrome but not working in Mozilla Firefox. can anyone suggest how to find control firing event?
推荐答案
通事件功能:
<asp:linkButton id ="target" style =" cursor:pointer" onclick ="fun(event, '1')" >click here </asp:LinkButton>
function fun(event, userID)
{
event= event|| window.event;
var btn = event.target;
alert(btn.id);
}
或
请确保您的活动是不是未定义
Make sure your event is not undefined
function fun(userID)
{
var e = event || window.event;
var btn = e.target;
alert(btn.id);
}
这篇关于JavaScript的event.target在Mozilla工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!