How to change text color in IFrame

I have a html page with an IFrame attached to a text file, the body of the html page is set to black, and the default color for the IFrame txt is black, so I cannot see my text: / I would like to know how to change the color of the text, thanks . zeokila

<iframe src="http://wordpress.org/extend/plugins/about/readme.txt" width="470" frameborder="0" marginheight="0" marginwidth="0" style="overflow-x:hidden"></iframe> 
+6
source share
1 answer

This does the trick, at least in FF, IE, and Opera.

 document.getElementById('your_iframe_id').contentWindow.document.body.style.color='white'; 

In Chrome, you can change the background color of an IFRAME :

 document.getElementById('your_iframe_id').style.background='white'; 

And to change the background color in IE:

 document.getElementById('your_iframe_id').contentWindow.document.body.style.backgroundColor='yellow'; 

Then there is a big one, but ... those expressions, including contentWindow , only work if the iframe and host page are in the same domain.

(By default, IE has only a white background)

+2
source

Source: https://habr.com/ru/post/913861/


All Articles