Hidden iframes don't work

Atom RSS

This site heavily relies on bug reports created by its readers. Anyone can report a bug and be published.

Main navigation:




Search reports by browser:

Safari doesn't count iframes with display: none at all. They are not represented in the frames array and refreshing the pages in them is impossible, too.

Test page. Workaround is not included.
Reported by ppk.

Safari | Reported on 22 February 2005.

Comments

(Add your own)

Posted by Simon Proctor on 22 February 2005

1

If you want to have a hidden iframe to load stuf into why not put it in a 0px by 0px div with overflow hidden?

This seems to work in Konqueror and every browser I've tried in Windows. Haven't got round to trying Safari yet.

Posted by ppk on 22 February 2005

2

In this particular case I didn't want a permanently hidden iframe. I used several iframes, all of which but one are hidden, and I wanted to load a new page into a hidden iframe and then make it visible.

That didn't work in Safari, I had to make the iframe visible first, and then load the new page into it.

Posted by Vesa Piittinen on 22 February 2005

3

Does the bug occur also when you place iframe inside a hidden div? Can't test myself, I don't have a Mac.

Posted by Bart van Deenen on 25 February 2005

4

iframes with visibility:hidden work fine on Safari. I use them all the time to simulate xml http requests

Posted by David Wheeler on 16 June 2005

5

Yes, Bart, they do work, but they don't show up in the frames[] array, which is the disappointing part. Anyone know of another way to get at the iframe's window object?

Posted by Arthur Hebert on 5 July 2005

6

Well, you can always call getElementsByTagName("iframe");

I haven't tested this for the current situation, but in general I find this method to be more reliable than built-in support for special arrays. Good luck!

Posted by Noah on 10 August 2005

7

You can do this hack to hide your iframe:

iframe.style.width = "0px";
iframe.style.height = "0px";
iframe.style.border = "0px";

It's ugly, I know, but it works in Safari. However it does weird things in Mac IE, as it will still show scrollbars depending on what you have overflow set to...

Of course style.display="none" still works properly in Mac IE...

Posted by Brad Neuberg on 31 August 2005

8

You can also make it visible but move it off the page:

position: absolute;
top: -500px;
left: -500px;

This will move it off the page, but still make it visible to the DOM.

Post a comment

Commenting guidelines:

  1. When quoting specs, articles or your own research, please include a URL of the document.
  2. Test your stuff. When reporting browser behaviour, make sure that your report is correct.

Yes