Chrome extension not loading EventListener

前端 未结 2 1926
轻奢々
轻奢々 2021-01-28 16:43

I\'ve been creating a chrome extension that splits my new tab pages into 2 frames so I can try to load 2 different URLs. Right now I\'ve started off simple, but I can\'t get the

相关标签:
2条回答
  • 2021-01-28 17:03

    Move this script from Bakcground.html to Left@Right.html

    <script type="text/javascript" src="script.js"></script> 
    

    And then in the script.js remove the "." before click

    document.getElementById("loader").addEventListener.("click", loadUrl);
    

    the above line should be

    document.getElementById("loader").addEventListener("click", loadUrl);
    
    0 讨论(0)
  • 2021-01-28 17:16

    In your manifest.json file, you should add a key, that indicates whenever to run your .js scripts.

    You should place it under "content_scripts" as following:

    {
    ...
        "content_scripts": [{
            "run_at": "document_end",
    ...
    

    "document_end" indicates that your code should run after the document, of the current tab, was loaded.

    0 讨论(0)
提交回复
热议问题