Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > IE7 won't let me define iframe background color

Reply
Thread Tools

IE7 won't let me define iframe background color

 
 
AAaron123
Guest
Posts: n/a
 
      12-09-2008

A iframe element always shows white background in IE7.

In Firefox it shows the color defined in the class attribute.

Can I get IE7 to do likewise somehow?

Thanks in advance



I have the following in a context file:

<asp:Content ID="Content2" ContentPlaceHolderID="RightCPH" runat="server">

<div id="Div3" runat="server" class="MainMasterDataNormal" >

<h5>ARTICLES </h5>

</div>



<%-- Must use name per test and documentation. With Id target does not work.
Opens in new window--%>

<iframe name="ArticlesFrame" frameborder="0" src="Make Black.htm"
class="MainFrame" height="533">

</iframe>

</asp:Content>



The Style sheet file contains:

..MainFrame

{

background-color: black;

width: 95%;

margin: 10px;

}

Which sets the margin and width OK but not the backgroung color.

I can force the color by including:

src="Make Black.htm"

which has a black background, but I really want it to either use the class
or else inherit from the container background color.










 
Reply With Quote
 
 
 
 
Joern Schou-Rode
Guest
Posts: n/a
 
      12-09-2008

On Tue, 09 Dec 2008 17:21:38 +0100, AAaron123 <>
wrote:

> Can I get IE7 to do likewise somehow?


Most likely not.

Wouldn't it make more sence, to instead change the background color
directly in the document loaded into the iframe?

--
Joern Schou-Rode
http://malamute.dk/
 
Reply With Quote
 
 
 
 
AAaron123
Guest
Posts: n/a
 
      12-09-2008

I give the user the option of selecting one of four style sheets and I'm not
sure how to get that info into the html file, but I'm going to think some
more about doing it that way?

Thanks

"Joern Schou-Rode" <> wrote in message
newsp.ulw1kzwg31zpn8@marvin...
> On Tue, 09 Dec 2008 17:21:38 +0100, AAaron123 <>
> wrote:
>
>> Can I get IE7 to do likewise somehow?

>
> Most likely not.
>
> Wouldn't it make more sence, to instead change the background color
> directly in the document loaded into the iframe?
>
> --
> Joern Schou-Rode
> http://malamute.dk/



 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      12-09-2008
On Dec 9, 5:21*pm, "AAaron123" <aaaron...@roadrunner.com> wrote:
> A iframe element always shows white background in IE7.
>
> In Firefox it shows the color defined in the class attribute.
>
> Can I get IE7 to do likewise somehow?
>
> Thanks in advance
>
> I have the following in a context file:
>
> <asp:Content ID="Content2" ContentPlaceHolderID="RightCPH" runat="server">
>
> <div id="Div3" runat="server" class="MainMasterDataNormal" >
>
> <h5>ARTICLES </h5>
>
> </div>
>
> <%-- Must use name per test and documentation. With Id target does not work.
> Opens in new window--%>
>
> <iframe name="ArticlesFrame" frameborder="0" src="Make Black.htm"
> class="MainFrame" height="533">
>
> </iframe>
>
> </asp:Content>
>
> The Style sheet file contains:
>
> .MainFrame
>
> {
>
> background-color: black;
>
> width: 95%;
>
> margin: 10px;
>
> }
>
> Which sets the margin and width OK but not the backgroung color.
>
> I can force the color by including:
>
> src="Make Black.htm"
>
> which has a black background, but I really want it to either use the class
> or else inherit from the container background color.


This is because background of the iframe is overlayed with background
of the source document. In your case you see the white document over
black iframe. To set the background use iframe's ALLOWTRANSPARENCY
attribute and set the background-color attribute of the BODY element
must be set to transparent.

Example:

main.htm

....
<iframe class="MainFrame" src="iframe.htm" ALLOWTRANSPARENCY="true"></
iframe>
....

iframe.htm

....
<body style="background-color:transparent">
....

OR you can also use javascript, for example

<script>
document.all.f.style.backgroundColor = "red";
</script>

where "f" is id of the iframe object (<iframe id="f"...

More about this
http://msdn.microsoft.com/en-us/library/ms535258.aspx

Hope this helps

 
Reply With Quote
 
AAaron123
Guest
Posts: n/a
 
      12-09-2008
I didn't have to think long.
Once the frame is loaded I have no problem.
The problem I have is the iframe background color before the user selects
something to load the iframe with.

The white blank iframe is stark.

I made a mistake in the post. I said:
<iframe name="ArticlesFrame" frameborder="0" src="Make Black.htm"
class="MainFrame" height="533">

I should have said
<iframe name="ArticlesFrame" frameborder="0" class="MainFrame" height="533">

Which is why I said
I can force the color by including:

src="Make Black.htm"

But I don't always want black.

Once I assign a real value to src the background is not visible.

Below I reproduce the post - corrected

Thanks
=============


An iframe element always shows white background in IE7.

In Firefox it shows the color defined in the class attribute.

Can I get IE7 to do likewise somehow?

Thanks in advance



I have the following in a context file:

<asp:Content ID="Content2" ContentPlaceHolderID="RightCPH" runat="server">

<div id="Div3" runat="server" class="MainMasterDataNormal" >

<h5>ARTICLES </h5>

</div>

<iframe name="ArticlesFrame" frameborder="0" class="MainFrame" height="533">

</iframe>

</asp:Content>



The Style sheet file contains:

..MainFrame

{

background-color: black;

width: 95%;

margin: 10px;

}

Which sets the margin and width OK but not the backgroung color.

I can force the color by including:

src="Make Black.htm"

which has a black background, but I really want it to either use the class
or else inherit from the container background color.






 
Reply With Quote
 
AAaron123
Guest
Posts: n/a
 
      12-10-2008

"Alexey Smirnov" <> wrote in message
news:05fb6005-d324-441b-b335-...
On Dec 9, 5:21 pm, "AAaron123" <aaaron...@roadrunner.com> wrote:
> A iframe element always shows white background in IE7.
>
> In Firefox it shows the color defined in the class attribute.
>
> Can I get IE7 to do likewise somehow?
>
> Thanks in advance
>
> I have the following in a context file:
>
> <asp:Content ID="Content2" ContentPlaceHolderID="RightCPH" runat="server">
>
> <div id="Div3" runat="server" class="MainMasterDataNormal" >
>
> <h5>ARTICLES </h5>
>
> </div>
>
>

<iframe name="ArticlesFrame" frameborder="0"
> class="MainFrame" height="533">
>
> </iframe>
>
> </asp:Content>
>
> The Style sheet file contains:
>
> .MainFrame
>
> {
>
> background-color: black;
>
> width: 95%;
>
> margin: 10px;
>
> }
>
> Which sets the margin and width OK but not the backgroung color.
>
> I can force the color by including:
>
> src="Make Black.htm"
>
> which has a black background, but I really want it to either use the class
> or else inherit from the container background color.


This is because background of the iframe is overlayed with background
of the source document. In your case you see the white document over
black iframe. To set the background use iframe's ALLOWTRANSPARENCY
attribute and set the background-color attribute of the BODY element
must be set to transparent.

Example:

main.htm

....
<iframe class="MainFrame" src="iframe.htm" ALLOWTRANSPARENCY="true"></
iframe>
....

iframe.htm

....
<body style="background-color:transparent">
....

OR you can also use javascript, for example

<script>
document.all.f.style.backgroundColor = "red";
</script>

where "f" is id of the iframe object (<iframe id="f"...

More about this
http://msdn.microsoft.com/en-us/library/ms535258.aspx

Hope this helps



=============
I had a bug in my post. I fixed above by removing
src="Make Black.htm"
from the iframe element.

You see how much that changes the problem?
There is no src value. The iframe opens without an overlay. When the user
makes a selection the attribute src is set equal to something.
So I tried to set the iframe background color to something pleasing until a
selection is made.

Thanks




 
Reply With Quote
 
Alexey Smirnov
Guest
Posts: n/a
 
      12-10-2008
On Dec 10, 2:10*am, "AAaron123" <aaaron...@roadrunner.com> wrote:
> I had a bug in my post. I fixed above by removing
> src="Make Black.htm"
> from the iframe element.
>
> You see how much that changes the problem?
> There is no src value. The iframe opens without an overlay. When the user
> makes a selection the attribute src is set equal to something.
> So I tried to set the iframe background color to something pleasing until a
> selection is made.
>
> Thanks


Aaron,

It seems this is by design in IE. It shows white by default.

I don't know if it helps, here's the trick I found with Microsoft
Visual Filter. If you set a background of a page and the opacity of an
object to 0 (100% transparent) you will "see" the transparent iframe
over the page.

<span style="background-color: yellow;">
<iframe style="filterrogidXImageTransform.Microsoft.Al pha
(opacity=0);" width="200" height="200"></iframe>
</span>

However I think your idea with src="Make Black.htm" is much simpler

 
Reply With Quote
 
AAaron123
Guest
Posts: n/a
 
      12-10-2008
Thanks for working with me

"Alexey Smirnov" <> wrote in message
news:0a45170b-0f48-4278-b46b-...
On Dec 10, 2:10 am, "AAaron123" <aaaron...@roadrunner.com> wrote:
> I had a bug in my post. I fixed above by removing
> src="Make Black.htm"
> from the iframe element.
>
> You see how much that changes the problem?
> There is no src value. The iframe opens without an overlay. When the user
> makes a selection the attribute src is set equal to something.
> So I tried to set the iframe background color to something pleasing until
> a
> selection is made.
>
> Thanks


Aaron,

It seems this is by design in IE. It shows white by default.

I don't know if it helps, here's the trick I found with Microsoft
Visual Filter. If you set a background of a page and the opacity of an
object to 0 (100% transparent) you will "see" the transparent iframe
over the page.

<span style="background-color: yellow;">
<iframe style="filterrogidXImageTransform.Microsoft.Al pha
(opacity=0);" width="200" height="200"></iframe>
</span>

However I think your idea with src="Make Black.htm" is much simpler


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Default background color of IFRAME Julian HTML 3 06-17-2009 08:11 AM
iFrame background color without using "allowTransparency" Bill Burke HTML 0 09-11-2005 07:29 PM
Problem with setting background color alternating item in datalist to a certain color fig000 ASP .Net Web Controls 0 09-06-2004 06:51 PM
Get form values from iframe (1) to iframe (2) inside a layer in iframe (1) Daedalous Javascript 3 01-16-2004 11:08 AM
<IFRAME> problem with text/background color in netscape foo HTML 4 10-02-2003 12:43 PM



Advertisments