Reputation: 416
Is there a way to create a Chrome extension to trick a site loaded in an iFrame into thinking it's not in a frame?
We load clients' sites into an iframe for demos, but some resources get blocked due to them disallowing being loaded in an iFrame. We'd like to load these sites into a frame as though you were browsing directly to the site in a standalone tab.
Upvotes: 1
Views: 869
Reputation: 24541
You should use the Chrome's webRequest
in order to intercept the server response. See the API. Here you go for onHeadersReceived
event where you are in control of any response headers => you need to remove X-Frame-Options
header from the response.
That's pretty much it, if this is the only problem in loading those sites.
However, for the sake of completeness, in order to fully trick the browser (which you most likely do not need) you need also to inject a script into every page that would clear up some things like window.parent
by simple removing them from window
object and some other things like origin etc. However removing the header would work for 99.9999% of your use cases.
Upvotes: 2