1

I build a Chrome extension which loads an external url in an iframe in the popup that is shown when the extension icon is clicked.

Is it possible to inject css inside that iframe so that I can make that site show more properly inside the popup?

I cannot use tabs.insertCSS, since this page is shown inside the extension popup and also I don't want to add the CSS to the website itself, as visitors to the website should be able to see it as it originally should be.

yannisc
  • 21
  • 7
  • Any reason you can't use the [standard DOM methods](https://www.google.com/#q=how+to+inject+css+in+iframe)? – wOxxOm Sep 24 '16 at 17:54
  • @wOxxOm, can you please be more specific? – yannisc Sep 24 '16 at 19:12
  • As you can see by clicking the link in my comment there are lots of specific answers. So your question should describe why the existing methods don't work in your case, what is the error and other specifics. – wOxxOm Sep 24 '16 at 20:06
  • The answer to the question you have asked is "Yes". If you want something more specific, then [edit] your question to be more specific to your situation. As wOxxOm has mentioned, please describe why the existing/common methods don't work for you. At which point, you will need to provide a [mcve] so we can duplicate the issue that you have with those methods. – Makyen Sep 24 '16 at 20:51
  • Possible duplicate of [How to apply CSS to iframe?](http://stackoverflow.com/questions/217776/how-to-apply-css-to-iframe) – Makyen Sep 24 '16 at 20:51
  • The link you provide talk about injecting css in iframes in general. My question is specific about iframes in chrome extension popups. – yannisc Sep 25 '16 at 06:11
  • So to sum up your question: you want to open a site in an iframe inside a popup (which isn't a normal tab, so you can't use `tabs.insertCSS`), and apply extra CSS to it; at the same time, you don't want that CSS applied when the site is opened normally. Is my understanding correct? Do you want that CSS to be always applied in this situation? – Xan Sep 26 '16 at 11:58
  • @Makyen As I understand the qeustion: the iframe is cross-origin, so standard DOM methods are likely to fail; the question is how to use the extended toolset provided by extensions to achieve it. – Xan Sep 26 '16 at 12:00
  • @Xan and Makyen, you are right. – yannisc Sep 26 '16 at 19:32
  • @yannisc Then please add what I summarized to the question itself, to make it more concrete (and interesting) – Xan Sep 26 '16 at 19:33

0 Answers0