Applying background to Iframe [IE / Firefox /Safari / Opera

August 2, 2007 at 3:00 am 3 comments

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;
<html xmlns=”http://www.w3.org/1999/xhtml”&gt;
<head>

<style>
#subscribe{
background:#ff0000;

}
</style>
<SCRIPT LANGUAGE=”JavaScript”>
function change_background() {
var iframeDoc;
if (window.frames && window.frames.subscribe && (iframeDoc = window.frames.subscribe.document)) {
// now use iframeDoc here
iframeDoc.body.style.backgroundColor=’red’;
//alert(iframeDoc.body.style.backgroundColor);
}

}
</SCRIPT>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″ />
<title>Untitled Document</title>
</head>

<body onLoad=”change_background();”>
<iframe src=”test1.html” id=”subscribe” name=”subscribe” scrolling=”no” frameborder=”0″></iframe>
</body>

</html>

Entry filed under: Javascript.

Arrays / Populating arrays / Sorting in Javascript Scroll / Scroller in css

3 Comments Add your own

  • 1. Daniel Tome  |  July 30, 2008 at 3:07 am

    Hi,

    This will only work on iframes that are under the same domain.

    cheers,

    Reply
  • 2. I T  |  October 8, 2010 at 8:41 pm

    good

    Reply
  • 3. ebook reader review  |  November 15, 2011 at 8:12 am

    Excellent submit, very informative. I’m wondering why the other specialists of this sector do not realize this. You must proceed your writing. I’m confident, you’ve a huge readers’ base already!|What’s Going down i’m new to this, I stumbled upon this I have discovered It absolutely useful and it has aided me out loads. I hope to contribute & assist different customers like its aided me. Great job.

    Reply

Leave a reply to Daniel Tome Cancel reply

Trackback this post  |  Subscribe to the comments via RSS Feed


Flickr Photos

Top Clicks

  • None

Blog Stats

  • 732,873 hits