BG Colour on Iframes

liunx

Guest
Hi,<br />
<br />
Im trying to work out how to set a bg colour on an iframe embedded in a page I am writing. I have seen a few code snippets but none seem to work.<br />
<br />
As a sideline, if there are any asp guru's around, would any of them happen to know if cmdExec supports a BGColor function? and if so, can it be applied to an iframe :-S<br />
<br />
The second question is not too important as I can always figure a way round that. Thanks in advance.<br />
<br />
Mr H.<!--content-->well doesn't the iframe load a page? and in that page you have a body tag? can't you insert the background color in the body tag?<br />
<br />
I don't play with iframes or frames but I would think you can do that.<!--content-->Scout pretty much has it nailed down. if the page is from the same domain you could use cross fram scripting to modify the style attributes of the body. If it is from another domain forget it, you are not going to change the background. ASP and other scripting is not going to help. Cross-domain security prevents you from changing a page you do not own.<!--content-->I should have explained that sorry. The Iframe is used as a rich text editor in my content manager. So I dont really want to load a page inside the frame. Also - If I set it inside the frame, I dont think I will be able to assign a bg color to the article that is being created :-S<!--content-->ahh if it is a text editor then you might be out of luck. the editor takes the background of the users Windows windows color for their editors<!--content-->For anyone that might find it useful, I have now come up with a solution, courtesy of MSDN.<br />
<br />
In header section use:<br />
<br />
<script language="javascript"><br />
function change_background() {<br />
document.frames.MYIFRAMENAME.document.body.style.backgroundColor="F4F4F4";<br />
}<br />
</script><br />
<br />
And in opening body tag insert<br />
<br />
onLoad="change_background()"<!--content-->and how is that different than <br />
<br />
in the iframe page<br />
<body bgcolor="#F4F4F4"><!--content-->because my iframe does not have a source file. its a blank iframe used as a rich text editor.<!--content-->where are you putting this<br />
<br />
onLoad="change_background()"<br />
<br />
in the iframe or the main page supporting the iframe?<br />
<br />
is that the whole purpose of this page? if so then I can see how it would work, but if the page has other uses (loading other pages in itself through serverside coding) then I could see it giving errors because it couldn't find the iframe.<br />
<br />
so can I see what is in the <iframe> tags? maybe I can't see how this is working.<!--content-->ok onLoad="change_background()" is in the main document body tag, and just applies the designated colour to the iframe once it is loaded. some code snippets below...<br />
<br />
HEADER<br />
<br />
<html><br />
<head><br />
<br />
<script language="javascript"><br />
function change_background() {<br />
document.frames.editwindow.document.body.style.backgroundColor="F4F4F4";<br />
}<br />
</script><br />
<br />
BODY TAG<br />
<br />
<body bgcolor="#ffffff" text="#000000" topmargin=0 leftmargin=0 bottommargin=0 onLoad="change_background()"><br />
<br />
IFRAME LOADER<br />
<br />
<tr><br />
<td align=right valign=bottom height=330 width="573"><iframe width="557" id="editwindow" height="330" frameborder=0 style="border:2px ridge #000000"></iframe></td><br />
</tr><!--content-->ok thanks, I was just thinking of some other way. I see how this works now.<!--content-->
 
Back
Top