Here's the documentation on it:
https://developer.mozilla.org/En/Using_JSON_in_Firefox
- Atul
postMessage automatically encodes whatever you pass it, including
objects, and on the other side onMessage automatically decodes the
message. Your message only has to be JSONable, e.g., it can't be a
function, and if your object includes a method, the method won't be encoded.
You can encode your message yourself, no harm, but there shouldn't be
any need. It'll end up being double encoded, and you'll have to decode
it yourself in onMessage.
Drew
On 3/15/11 7:28 PM, pd wrote:
> How do create a HTML element that will be able to send a postMessage
> back to main.js when clicked?
>
I'm not sure if this answers your question, but you could also take a
look at the annotator example code, for example under
annotator/data/editor, which includes HTML and a content script for a
panel that hosts a textarea and sends the contents of the textarea to
the add-on when the user presses <return>.
Will
Regarding JSON and other kinds of APIs, the Chrome Extensions
documentation has a nice page on "Other APIs" that provide a broad
overview of what else is available, along with pointers to more
documentation:
http://code.google.com/chrome/extensions/api_other.html
Might be useful to integrate similar things into our docs, although I
believe we've already got some of it mentioned on the Globals section.
- Atul
This won't work since postMessage is called by a page not a content
script. You should use addEventListener in which case postMessage will
bee called from content script
> --
> You received this message because you are subscribed to the Google Groups "mozilla-labs-jetpack" group.
> To post to this group, send email to mozilla-la...@googlegroups.com.
> To unsubscribe from this group, send email to mozilla-labs-jet...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mozilla-labs-jetpack?hl=en.
>
>
--
Regards
--
Irakli Gozalishvili
Web: http://www.jeditoolkit.com/
Address: 29 Rue Saint-Georges, 75009 Paris, France <http://goo.gl/maps/3CHu>
If it's the whole directory structure, you're better off creating a
github account and making your project into a git repository, which will
allow other folks to post comments on your code. They've got a great
"github bootcamp" series to help you get started:
Hope that helps.
- Atul