gpt4 book ai didi

javascript - 即使不在参数中也设置事件变量

转载 作者:行者123 更新时间:2023-11-28 20:31:18 24 4
gpt4 key购买 nike

给出以下代码:

openUserProfile: function(){
event.preventDefault();

// Rest of function
}

在 Firefox 中,它会按预期抛出 ReferenceError: event is not Define,因为 event 未作为参数传入。然而,在 Chrome 和 Safari 中,定义了 event,因此上面的代码运行良好。

这有什么解释吗?

最佳答案

浏览这个线程; window.event 未在 FF 中定义

Javascript Error in FireFox Not in IE and Chrome

试试这个:-

openUserProfile: function(e){
e.preventDefault();

// Rest of function
}

关于javascript - 即使不在参数中也设置事件变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16313033/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com