简体   繁体   中英

Modify event variable in JavaScript

Is there a way to modify the event variable (IE: window.event, others: e) in JavaScript? I know you can easily clone it, using a quick loop copy. However, the browser won't let you do that for methods like e.preventDefault() and such. So, I'm looking for another way to do it.

(Yes, I know it probably isn't a good idea. But I want to do it anyways.)

Well (keeping in the back of your mind RobG's comment), you can add methods to the prototype of Event , and you can overwrite native methods in the Event.prototype .

Like in this jsfiddle . Is that what you meant?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM