Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change style of iframe content cross-domain?

Tags:

I want to make background color black and text color white for the content inside iframe from its default of normal white background and black text. The iframe src attribute points to different domain to which I have no access or cannot place any file or stylesheets in that domain. So given these conditions is it possible to make just these style changes in the iframe content and if so then how?

like image 451
ace Avatar asked Jan 18 '11 13:01

ace


People also ask

Can you change iframe content style?

You can not change the styles of the page that resides within the iframe.

Can I load an iframe from a different domain?

Generally, web application allows script running between pages(parent and iframe pages) in the same domain based on same-origin-policy. Unfortunately it does not support scripts if different domain. The policy does not allow it.

Can I customize iframe?

The iFrame embed code can be easily customized directly from the embed code. Often when a form is embedded with an iFrame there is a default scrolling bar if the form is larger than the iFrame. In order to avoid this, there are two options that can be added to easily adjust the iFrame.

Can we style elements iframe?

We can use inline CSS for the iframe by using CSS inside the iframe tag. Example: The design of the HTML page is implemented as follows.


1 Answers

The only possibility would be to load the iframe content through a proxy of yours and modify the HTML content. You can not access iframes from another domain via JavaScript.

like image 133
Sean Patrick Floyd Avatar answered Sep 20 '22 11:09

Sean Patrick Floyd