I have following in my contentscript.js
document.addEventListener('click', function (event: MouseEvent) {
event.preventDefault();
event.stopPropagation();
}, false);
The listener is called but the click in not captured/prevented and is propagrated. Is there a way to achieve this ?
Since the listener is attached to the document, I had to use the capture
parameter to preventDefault
while the event "bubbles" up.
document.addEventListener('click', function (event) {
event.preventDefault();
}, {capture: true});
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.