Kikun
Kikun

Reputation: 17

Firefox extension access from iframe

I have an iframe in my extension with code like this:

<html:iframe src="http://link.com/" id="iFrame" flex="1" type="content" />

And in my main.js I have an variable:

var myVarExt='Good!';

But when I'm trying to access it from the iframe with code:

alert(parent.myVarExt);

In the Browser Console I'm getting an error:

Error: Permission denied to access property 'myVarExt'

How can I fix it?

Upvotes: 0

Views: 318

Answers (1)

Yolanda Ruiz
Yolanda Ruiz

Reputation: 696

You cannot do this because it would break the security model. The web page loaded in the IFrame has lower privileges than the extension itself. Remember that your extension has access to the user's file system and can read or delete files, imagine if arbitrary web pages could add methods to your extension's objects and then call into them.

For communication between content code and extension code, please refer to Interaction between privileged and non-privileged pages.

You use custom DOM events to send data between the web page and the extension.

Upvotes: 2

Related Questions