• Login
    • Search
    • Categories
    • Recent
    • Tags
    • Users
    • Groups
    • Rules
    • Help

    Do more on the web, with a fast and secure browser!

    Download Opera browser with:

    • built-in ad blocker
    • battery saver
    • free VPN
    Download Opera

    Settings page problem of my extension.

    Opera add-ons
    2
    2
    914
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • master94ga
      master94ga last edited by

      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 🙂

      Reply Quote 0
        1 Reply Last reply
      • cinusek
        cinusek last edited by

        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:

        • https://dev.opera.com/extensions/tut_architecture_overview.html#permissions_and_privileges
        • https://developer.chrome.com/extensions/contentSecurityPolicy
        Reply Quote 0
          1 Reply Last reply
        • First post
          Last post

        Computer browsers

        • Opera for Windows
        • Opera for Mac
        • Opera for Linux
        • Opera beta version
        • Opera USB

        Mobile browsers

        • Opera for Android
        • Opera Mini
        • Opera Touch
        • Opera for basic phones

        • Add-ons
        • Opera account
        • Wallpapers
        • Opera Ads

        • Help & support
        • Opera blogs
        • Opera forums
        • Dev.Opera

        • Security
        • Privacy
        • Cookies Policy
        • EULA
        • Terms of Service

        • About Opera
        • Press info
        • Jobs
        • Investors
        • Become a partner
        • Contact us

        Follow Opera

        • Opera - Facebook
        • Opera - Twitter
        • Opera - YouTube
        • Opera - LinkedIn
        • Opera - Instagram

        © Opera Software 1995-