Settings page problem of my extension.

  • Hello!
    I'm doing an extension, now I'm working on the settings page. My settings page work perfectly in local but when I try it on the extensions doesn't work. The problem is related to buttons, they doesn't go to the functions while on local they works.

    Two file download: https://dl.dropboxusercontent.com/u/22722558/Settings.zip

    Thanks for help :)

  • You are using inline scripts in the settings.html page (in form of onclick="..." element attributes) which is forbidden by default in extensions. There should be error messages about this in the developer tools console for the options page.

    The best way to fix this is to use addEventListener in settings.js to register the click event handlers on the appropriate elements.
    E.g. you can add the following code to your settings.js:

    function init() {
      document.getElementById('Button1').addEventListener('click', Save, false);
      document.getElementById('Button2').addEventListener('click', Load, false);
      document.getElementById('Button3').addEventListener('click', Default, false);
    }
    
    window.addEventListener('load', init, false);
    

    And remove the onclick=... stuff from the HTML.

    Inline scripts are forbidden in extensions by default for security reasons. You should put all your JavaScript code in JS files and not in HTML.
    You can read more about the Content Security Policy in extensions (and how to allow exceptions) in the documentation:

Log in to reply
 

Looks like your connection to Opera forums was lost, please wait while we try to reconnect.