Henkie

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromHenkie
ToMe
SubjectFYI
Date11 December 2007 01:09
Hello Mark,

I stubbled upon a funny bug (?) when making 
[URL]
Code: |<iFrame style="background-color:White;">|

Firefox: okay
MSIE: ignored
Opera: ignored

It gets even funnier when |style="background-color:White;"| is omitted:
Firefox displays the iFrame with the same background colour as the page 
containing it (in this case a blueish colour).

No response needed as I suspect it's unsolvable at this point in time.

Regards,
][enkie
FromMe
ToHenkie
SubjectRe: FYI
Date11 December 2007 08:43
Henkie,

> Code: |<iFrame style="background-color:White;">|
>
> Firefox: okay
> MSIE: ignored
> Opera: ignored

This is very easy to solve.
1. Firefox and Safari default to transparent backgrounds for pages in inline
frames. Nothing needed.
2. Opera and IE need the page inside the iframe to specifically request 
that its background be transparent (otherwise it gets the default white, or
whatever the user has chosen):
html, body { background: transparent; }
3. IE also needs the following attribute on the iframe:
allowtransparency="true"


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromHenkie
ToMe
SubjectiFrame background
Date12 December 2007 11:12
Mark,

"Does not compute" in my mind.... With the style-attribute I explicitly
declare what the background should look like (unless overruled by the
framed page), so  Opera & MSIE should do what's told to the browser.

Regards,
Henkie
FromMe
ToHenkie
SubjectRe: iFrame background
Date12 December 2007 13:42
Henkie,

> With the style-attribute I explicitly declare what the background should
> look like

You have told it what background colour to make the inline block where the
inline frame will be placed. However, an inline frame is an inline replaced
element. It is replaced (effectively overlayed) by the rendering of another
Web page.

By default, all Web pages receive a background colour, which defaults to a
colour chosen by the user - typically defaulting to white, but often grey in
older browsers. You can see this by opening an unstyled Web page in a
browser window (not an inline frame) - it gets a default background colour,
and does not produce a transparent window. The default colour is typically
applied to the root node (HTML element) of the document, which is propagated
to the viewport (the inline frame's overlay).

For reasons best known to themselves, Firefox and Safari make this default
background transparent for pages that are held in inline frames. This is
inconsistent with the user's preferences, and in some cases can even cause
the contents to become invisible (such as if the background of the parent
page was black). This is actually an intentional bug in these browsers.

Opera and IE default to the colour chosen by the user, or whatever is
specified by the page inside the inline frame. So even though they correctly
set the background colour of the inline block on the parent page to the
colour you request, it is then overlayed by the page inside the inline frame
(which has its own background colour), so you cannot see your chosen colour.
This is correct behaviour for replaced elements and is in accordance with
CSS.

When you specify the background colour as transparent for the page inside
the inline frame (which is overlaying the inline block which has your chosen
colour), the underlaying inline block can then show through, along with
whatever background colour it has. This is also the correct behaviour.

For legacy reasons (relating to how IE used to create the overlay), IE also
needs the attribute on the iframe element. This is not part of any standard,
and is just IE's chosen behaviour.

Tarquin
FromHenkie
ToMe
SubjectRe: iFrame background
Date12 December 2007 14:47
Hi mark,

Thanks for clearing it up.

> This is actually an intentional bug in these browsers.

Final questions:
- what motive do Firefox and Safari have to do so?
- what is the link at your site where you place this subject?

Regards,
][enkie
FromMe
ToHenkie
SubjectRe: iFrame background
Date14 December 2007 17:31
Henkie,

> - what motive do Firefox and Safari have to do so?

You would have to ask them. Perhaps they assume more people will expect what
you expected.

> - what is the link at your site where you place this subject?

/emails/
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.