Keresés

Új hozzászólás Aktív témák

  • sztanozs

    veterán

    válasz Narasim #3 üzenetére

    A linkelt blogbejegyzésből vettem:

    How It Works
    If you wanted to share an object to the content, from your add-on code you would do something like this:

    var sharedObject = { foo : "Hello!" };
    contentWindow.wrappedJSObject.sharedObject = sharedObject;

    Then from a script in the content you can do something like this:

    alert(window.sharedObject.foo);

    And this would alert the text “Hello!” in the page. Starting with Firefox 17, this won’t work. The page will be able to see window.sharedObject, but none of its properties or functions will be visible. For it to work, you now must do this in your add-on code:

    var sharedObject = { foo : "Hello!", __exposedProps__ : { foo : "r"} };
    contentWindow.wrappedJSObject.sharedObject = sharedObject;

    The __exposedProps__ property is the whitelist that tells Firefox it’s okay to share foo with the content. The value can be “r” (read-only), “w” (write-only), or “rw” (read and write). You generally want to use “r”.

    Note that this only affects your add-on if you’re sharing objects with the content. If all you’re doing is passing values like numbers, booleans or strings, they should continue to work.

    [ Szerkesztve ]

    JOGI NYILATKOZAT: A bejegyzéseim és hozzászólásaim a személyes véleményemet tükrözik; ezek nem tekinthetők a munkáltatóm hivatalos állásfoglalásának...

Új hozzászólás Aktív témák