0

I am having trouble styling contents inside an Iframe. I can't change this, I don't know why it was build this way, but I need to be able to style some divs with css inside the iframe.

Any ideas are appreciated.

Deedub
  • 339
  • 2
  • 6
  • 18
  • 1
    content inside iframe will be styling according to css files loaded in document that is requested by url in iframe, not from css files of parent page – Mhmd Jul 01 '13 at 20:53
  • possible duplicate of [How to apply CSS to iFrame?](http://stackoverflow.com/questions/217776/how-to-apply-css-to-iframe) – Joseph Marikle Jul 01 '13 at 20:54

2 Answers2

0

content inside iframe will be styling according to css files loaded in document that is requested by url in iframe, not from css files of parent page

Mhmd
  • 4,671
  • 3
  • 19
  • 29
  • Cairo, can I then relink to the same css file in the root html? – Deedub Jul 01 '13 at 21:00
  • if you want to load same css file in both pages parent and child in iframe, no technical issue for this – Mhmd Jul 01 '13 at 21:45
  • here is what I am trying. – Deedub Jul 01 '13 at 22:02
  • the problem is not in your js code, if you are loading page2 in iframne successfully, go to page2 html and put meta tage of css file there. – Mhmd Jul 01 '13 at 22:05
  • thanks, got it. Was trying to do it with jquery, but was just as easy to go to iframe code. UGH. I hate editing themes. – Deedub Jul 01 '13 at 22:27
0

This is due to the Same Origin Policy: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Same_origin_policy_for_JavaScript

Due to security reasons, you aren't allowed to manipulate an external website's code within an iframe.

  • same server, I have no idea why I frames were used. – Deedub Jul 01 '13 at 21:02
  • As long as it's the same domain, try one of the methods from this top answer to see if it works for you: [Stack Overflow](http://stackoverflow.com/questions/10321653/styling-iframe-content) – Andrew Sapiens Jul 01 '13 at 21:24