Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I change the text color in IFrame

I have a html page with an IFrame linking towards a text file, my html page's body is set to black, and the default color of the IFrame txt is black, so I cannot see my text :/ I would like to know how to change the text color, 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> 
like image 619
Alexandre Hitchcox Avatar asked Apr 22 '12 19:04

Alexandre Hitchcox


People also ask

How do I change the Colour of text in HTML?

To set the font color in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <p> tag, with the CSS property color. HTML5 do not support the <font> tag, so the CSS style is used to add font color.

How do you change the text color of an element text color?

You can use the CSS color property to change the text color. This property accepts color values like Hex codes, RGB, HSL, or color names.


1 Answers

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

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

In Chrome you can only change IFRAMEs background color:

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

And for change background color in IE:

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

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

(It is IE only having that white background by default)

like image 183
Teemu Avatar answered Oct 12 '22 06:10

Teemu