简体   繁体   中英

window.chrome.webview.addEventListener vs. document.addEventListener

Which event listener is used for what?

  • window.chrome.webview.addEventListener
  • document.addEventListener

Are these synonyms or is there a difference? If yes, which?

From your comment:

Environment: It is used for display in a Delphi Edge component. The point is, however, to understand JavaScript.

Neither of these is specifically JavaScript. They're both external APIs provided to the JavaScript environment by the host environment. (The host environment in your case is apparently a Delphi Edge web browser control. Other examples are web browsers generally, or outside that realm there's Node.js, Deno, and some others.)

Of those two:

  • The first one is specific to the Delphi Edge component you asked about (perhaps more generally to the webview control that it uses).

  • The second, document.addEventListener , is the standard DOM API method for hooking into events (in this case at the document level rather than a specific element within the document). That's provided to JavaScript running in web browsers by the browser, and is available cross-browser.

If you're looking to do standard web programming and need to hook into an event at the document level, you'd use the second.

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