Forums
This topic is locked
iFrame manipulation
15 Sep 2006 12:04:28 darren b posted:
Is is possible to change the body class within iFrame's source HTML? Obviously the code below is not functional, it is for example only. I have tried several ideas but nothing I try seems to work.
Many thanks for any advice.
<pre id=code><font face=courier size=2 id=code>
<head>
<style>
.blue { background-color: blue; color: yellow; }
</style>
</head>
<body>
<iframe src="iframetest.htm" name="myiframe" width="200" height="300"></iframe>
<input type="button" name="Blue" value="Blue" onClick="document.body.myiframe.document.body.className='blue'">
</body> </font id=code></pre id=code>
Replies
Replied 22 Sep 2006 09:22:52
22 Sep 2006 09:22:52 Peter Svensson replied:
Hi
Try this out. I always use to call a function in the IFRAME source document in order to get access to the DOM.
Put this function in the document that holds the IFRAME.
function hookToIframeDoc(){
document.frames("YOUR_FRAME".alterFrameDoc(); //calls a function place in the IFRAME source document
}
Function placed in the IFRAME source document
function alterFrameDoc(){
document.body.style.backgroundColor = "whitesmoke";
}
Try this out. I always use to call a function in the IFRAME source document in order to get access to the DOM.
Put this function in the document that holds the IFRAME.
function hookToIframeDoc(){
document.frames("YOUR_FRAME".alterFrameDoc(); //calls a function place in the IFRAME source document
}
Function placed in the IFRAME source document
function alterFrameDoc(){
document.body.style.backgroundColor = "whitesmoke";
}
Replied 25 Sep 2006 10:29:56
25 Sep 2006 10:29:56 darren b replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
Hi
Try this out. I always use to call a function in the IFRAME source document in order to get access to the DOM.
Put this function in the document that holds the IFRAME.
function hookToIframeDoc(){
document.frames("YOUR_FRAME".alterFrameDoc(); //calls a function place in the IFRAME source document
}
Function placed in the IFRAME source document
function alterFrameDoc(){
document.body.style.backgroundColor = "whitesmoke";
}
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Awesome!
Thanks for you help Peter, much appreciated!
Hi
Try this out. I always use to call a function in the IFRAME source document in order to get access to the DOM.
Put this function in the document that holds the IFRAME.
function hookToIframeDoc(){
document.frames("YOUR_FRAME".alterFrameDoc(); //calls a function place in the IFRAME source document
}
Function placed in the IFRAME source document
function alterFrameDoc(){
document.body.style.backgroundColor = "whitesmoke";
}
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Awesome!
Thanks for you help Peter, much appreciated!