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

August 2, 2007

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”http://www.w3.org/1999/xhtml”>
<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. .

1 Comment 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,

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed


Spam Blocked

Flickr Photos

THE-GROUP-YOU-CANNOT-GET-INTO-ANYMORE

.pouting.

L'informarsi, prima di tutto

More Photos

Categories

Links

Calendar

August 2007
M T W T F S S
« Jul   Sep »
 12345
6789101112
13141516171819
20212223242526
2728293031  

Recent Posts

Recent Comments

Sachin Gajraj on Top 50 Govt Engineering C…
Sachin Gajraj on Top 50 Govt Engineering C…
KUSHAGRA on Top 50 Govt Engineering C…
Siber on 5 useful PHP functions for MyS…
Daniel Tome on Applying background to Iframe …

Pages

Top Clicks

Top Posts

Blog Stats