Problem:
A .html and .js file work properly when loaded in a regular browser, but when packaged in a Chrome or Firefox extension, the onClick event is nonfunctional.
Solution:
Chrome Extensions and Firefox WebExtensions do not support inline JavaScript.
Approach:
document.addEventListener('DOMContentLoaded', function() { var link = document.getElementById('link'); // onClick's logic below: link.addEventListener('click', function() { hellYeah('xxx'); }); });
The above is the detailed content of Why Aren't My onClick Events Working in Chrome/Firefox Extensions?. For more information, please follow other related articles on the PHP Chinese website!