Using a iframe where I call a site from my webspace, Using one css file with body {background-color: #222}
.
The iframe src also use this CSS file. The P
This question is similar to How to apply css to iframe content?. Basically you can use jQuery to change the CSS properties in the iframe
$('#yourIframe').contents().find('body').css({
background-color: '#333333'
});
Edit: You may need to add that when the iframe loads:
$('#yourIframe').load(function(){
$(this).contents().find('body').css({
background-color: '#333333'
});
});
ive used this and it works for me. (and its sooooo easy!)
in your CSS file put:
iframe { background-color:orange; }
Just change the "orange" to whatever color you need. Thats it!
Enjoy!
In the page that the iframe contains, link another stylesheet and then change all the CSS styles that you wish to.
using Javascript We can add Background Color to Iframe
var x = document.getElementById("myframe");
var y = (x.contentWindow || x.contentDocument);
if (y.document)y = y.document;
y.body.style.backgroundColor = "red";
Reference w3schools
I assume the iframe takes up a smaller portion of your site. In that case I would advice you to simply use a div with the same size of the iframe is loaded, and giving this div the proper background-color.
OR: include a style property in the source of the iframe page:
<head>
<style>body {background-color:#COLOR}</style>
</head>
Remember that a Javascript can modify only properties of iframe with the same origin of the site, otherwise you'll get a Security Error.
Protocols, domains and ports must match.