2

Is it possible to add eventListener with regex?

Something like this:

document.addEventListener(""+/\d+/+"", function (data) {
    // ...
}); 
vrintle
  • 5,501
  • 2
  • 16
  • 46
Dusty
  • 354
  • 4
  • 15

1 Answers1

0

It's impossible to attach an event listener to events by mask. You can take a list of events, here, for example and listen to all of them in a cycle to attach our handler to them.

Community
  • 1
  • 1
Vladislav Rastrusny
  • 29,378
  • 23
  • 95
  • 156
  • Thank you for the answer. I don't understand why in http://krasimirtsonev.com/blog/article/Send-message-from-web-page-to-chrome-extensions-background-script you can listen to "hello" and you can't use regex? – Dusty Nov 25 '15 at 12:13
  • @Dusty This is an interface for Chrome extensions: https://developer.chrome.com/extensions/runtime – Vladislav Rastrusny Nov 25 '15 at 12:15