Welcome guest, is this your first visit? Create Account now to join.
Results 1 to 2 of 2

This is a discussion on "Refused to execute inline event handler" within the Plugins Development section, part of the Chrome Plugins category: Hello all, I'm currently writing my first Chrome extension as a little hobby and I've run across a problem. The ...


  1. #1
    chrisfnet is offline Junior Member
    Join Date
    Oct 2012
    Posts
    1

    Default "Refused to execute inline event handler"

    Hello all, I'm currently writing my first Chrome extension as a little hobby and I've run across a problem. The problem is:

    Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".

    I have written a small calculator. The calculator works perfectly if I load up the HTML page and use it as anything but a Chrome extension. I've done some searching on my own and I was instructed to use the addEventListener() method rather than onClick(). I have done this but I still have the above problem for some reason. My popup.js code is as follows:

    Code:
    document.addEventListener('DOMContentLoaded', function () {
    	var calculate_button = document.getElementById('calculate_button');
    	calculate_button.addEventListener('click',calculateCrCl);
    });
    I have the button defined as:

    Code:
    <button id="calculate_button">Calculate</button>
    The calculation function simply calculates the number and the sets the .value for a textbox to that number.

    However, when I'm using the calculator as an extension, I get this security violation error and I'm not sure how to fix it.... any ideas?

  2. #2
    samhagin is offline Junior Member
    Join Date
    Mar 2013
    Posts
    2

    Default

    Inline javascript is not permitted in background.html for security reasons. You should instead put the javascript code in a file such as script.js then add this <script src="script.js"></script> to your background.html file.

Similar Threads

  1. Replies: 1
    Last Post: 10-30-2011, 02:36 PM
  2. Chrome "Glow" & "Late Night" Theme Buttons DON'T glow!!!! Help!!
    By Sinaola in forum Chrome Troubleshooting
    Replies: 3
    Last Post: 10-21-2010, 05:44 PM
  3. Replies: 4
    Last Post: 03-03-2010, 12:29 AM
  4. Replies: 6
    Last Post: 09-26-2009, 04:57 PM
  5. Google Chrome "Load unpacked extension" Button Does Not Exist
    By chayimf in forum Plugins Troubleshooting
    Replies: 4
    Last Post: 09-05-2009, 10:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •