Fluidbyte
Fluidbyte

Reputation: 5210

Chrome Extension Inject into iFrame with JavaScript

I'm working on a Chrome Extension that allows a user to open a site into an iframe in a new tab. My goal is to allow them to modify the CSS by injecting the code via JavaScript from the parent window, yet I'm getting blocked by origin-only issues.

Is there a way around this? I know I've seen other extensions do similar things.

Upvotes: 5

Views: 2974

Answers (1)

Mike Grace
Mike Grace

Reputation: 16914

I believe what you are looking for is the

chrome.tabs.executeScript

with allFrames set to true

Documentation can be found here https://developer.chrome.com/extensions/tabs#method-executeScript

This will allow you to inject a content script into a page and all iFrames in that page. There is also a similar function for injecting CSS : )

Upvotes: 5

Related Questions