Awea
Awea

Reputation: 3173

Firefox extension interacting with the DOM

May be my logic is wrong but I'm trying to send and receive datas between my extension and the content.

So I start with something like this to send data from my content to my extension :

var images_elements = [];
tabs.activeTab.attach({
  contentScript: "postMessage(document.getElementsByTagName('img'));",
  onMessage: function (message) {
    images_elements = message;
  }
});

Obviously, it doesn't work. How can I do something like this ? And How can I did it in the other way, example make something on this elements after making a require("sdk/request").Request and replace them in the content.

Upvotes: 2

Views: 82

Answers (1)

ZER0
ZER0

Reputation: 25322

You can send data, but the API accept only data that is JSON-serializable value.

DOM nodes are not in that category, that's why it doesn't work.

Upvotes: 1

Related Questions