• <i id='nZYrc'><tr id='nZYrc'><dt id='nZYrc'><q id='nZYrc'><span id='nZYrc'><b id='nZYrc'><form id='nZYrc'><ins id='nZYrc'></ins><ul id='nZYrc'></ul><sub id='nZYrc'></sub></form><legend id='nZYrc'></legend><bdo id='nZYrc'><pre id='nZYrc'><center id='nZYrc'></center></pre></bdo></b><th id='nZYrc'></th></span></q></dt></tr></i><div id='nZYrc'><tfoot id='nZYrc'></tfoot><dl id='nZYrc'><fieldset id='nZYrc'></fieldset></dl></div>
    <legend id='nZYrc'><style id='nZYrc'><dir id='nZYrc'><q id='nZYrc'></q></dir></style></legend>
  • <tfoot id='nZYrc'></tfoot>

    <small id='nZYrc'></small><noframes id='nZYrc'>

      • <bdo id='nZYrc'></bdo><ul id='nZYrc'></ul>

      1. Chrome 扩展:onclick() 事件未触发 alert() 弹出窗口

        时间:2023-09-04

            • <bdo id='qElnE'></bdo><ul id='qElnE'></ul>

                  <i id='qElnE'><tr id='qElnE'><dt id='qElnE'><q id='qElnE'><span id='qElnE'><b id='qElnE'><form id='qElnE'><ins id='qElnE'></ins><ul id='qElnE'></ul><sub id='qElnE'></sub></form><legend id='qElnE'></legend><bdo id='qElnE'><pre id='qElnE'><center id='qElnE'></center></pre></bdo></b><th id='qElnE'></th></span></q></dt></tr></i><div id='qElnE'><tfoot id='qElnE'></tfoot><dl id='qElnE'><fieldset id='qElnE'></fieldset></dl></div>
                    <tbody id='qElnE'></tbody>
                1. <small id='qElnE'></small><noframes id='qElnE'>

                  <tfoot id='qElnE'></tfoot>

                2. <legend id='qElnE'><style id='qElnE'><dir id='qElnE'><q id='qElnE'></q></dir></style></legend>
                  本文介绍了Chrome 扩展:onclick() 事件未触发 alert() 弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我无法通过 onclick() 事件触发 alert() 弹出窗口.

                  I am unable to trigger an alert() popup with an onclick() event.

                  {
                      "name": "Project",
                      "version": "1.0.0",
                      "manifest_version": 2,
                      "description": "Popup when website requires Log in",
                      "browser_action":{
                          "default_icon":"icon_19.png",
                          "default_popup":"Popup.html"
                          }
                  }
                  

                  文件Popup.html

                  <html>
                  <head></head>
                  
                  <body>
                      <div class="plus" onclick="popup()"></div>
                      <script src="inline.js"></script>
                  </body>
                  </html>
                  

                  文件inline.js

                  function popup() {
                      var link = document.URL;
                      alert("This is the link: (" + link + ")");
                  }
                  

                  推荐答案

                  不要在 Google Chrome 扩展程序中使用内联 JavaScript 代码.

                  Don't use inline JavaScript code in a Google Chrome extension.

                  HTML:

                  <div class="plus"></div>
                  <script src="inline.js"></script>
                  

                  JavaScript:

                  JavaScript:

                  function popup(e) {
                    var link = document.URL;
                    alert("This is the link: (" + link + ")");
                  }
                  
                  var plusBtn = document.querySelector('.plus');
                  plusBtn.addEventListener('click', popup);
                  

                  这篇关于Chrome 扩展:onclick() 事件未触发 alert() 弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:防止使用 JavaScript 刷新/重新加载页面 下一篇:jQuery 卸载事件仅适用于关闭窗口,不适用于链接

                  相关文章

                  最新文章

                  <legend id='AyZ5v'><style id='AyZ5v'><dir id='AyZ5v'><q id='AyZ5v'></q></dir></style></legend>

                      <tfoot id='AyZ5v'></tfoot>
                      • <bdo id='AyZ5v'></bdo><ul id='AyZ5v'></ul>

                    1. <small id='AyZ5v'></small><noframes id='AyZ5v'>

                      <i id='AyZ5v'><tr id='AyZ5v'><dt id='AyZ5v'><q id='AyZ5v'><span id='AyZ5v'><b id='AyZ5v'><form id='AyZ5v'><ins id='AyZ5v'></ins><ul id='AyZ5v'></ul><sub id='AyZ5v'></sub></form><legend id='AyZ5v'></legend><bdo id='AyZ5v'><pre id='AyZ5v'><center id='AyZ5v'></center></pre></bdo></b><th id='AyZ5v'></th></span></q></dt></tr></i><div id='AyZ5v'><tfoot id='AyZ5v'></tfoot><dl id='AyZ5v'><fieldset id='AyZ5v'></fieldset></dl></div>