How can Iframe access parent window in chrome extension

Viewed 4009

I have a page iframe.html in my chrome extension folder. And i wanna it show in my current web page. And here is the problem, how can i close the iframe when i click a button in the iframe? I have tried by code like this:

window.parent.iframe.hide()

But it doesn't work with error:

Unsafe JavaScript attempt to access frame with URL

But i read evernote clearly's source file. It has some code like

window.parent.$readable.hide()

Why evernote's extension works but my extension show some errors? Is here something i shoud do in my manifest.json? Here is my manifest file.

{
  "name": "Reader",
  "version": "1.0",
  "manifest_version": 2,
  "description": "A great start!",
  "browser_action": {
    "default_icon": "icon.png"
  },
  "background": {"scripts": ["background.js"]},
  "permissions": [
    "tabs", "<all_urls>"
  ],
  "web_accessible_resources": [
    "iframe/index.html"
  ]
}
1 Answers
Related