#Chrome Extension Messaging Sample
The JavaScript components of Chrome extensions have several restrictions due to cross-origin policy. This sample extension serves as boilerplate code for first-timers.
Comedy of restrictions:
background.jsruns independent of tabs.content.jsis tab-specific.- Only
background.jscan make web requests. - Only
content.jscan access DOM of the page. iframe.jscan neither access DOM nor make web requests.background.jscannot seeiframe.jsand must talk to it through the content script that injected it.
background.js, iframe.js, and content scripts must rely on each other using message passing for functions they cannot perform.
popup.js works like a content script.
Here's a working example of an extension made that uses iframes: Claw4Twitter, source