Hidden iframes don't work

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.

This site is no longer maintained. I’m sorry, but it’s just too much work for too little return. You can continue to browse old bug reports, though.




Search reports by browser:

Atom RSS

Comments

(Add your own)

1 Posted by Simon Proctor on 22 February 2005 | Permalink

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.

2 Posted by ppk on 22 February 2005 | Permalink

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.

3 Posted by Vesa Piittinen on 22 February 2005 | Permalink

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

4 Posted by Bart van Deenen on 25 February 2005 | Permalink

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

5 Posted by David Wheeler on 16 June 2005 | Permalink

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?

6 Posted by Arthur Hebert on 5 July 2005 | Permalink

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!

7 Posted by Noah on 10 August 2005 | Permalink

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...

8 Posted by Brad Neuberg on 31 August 2005 | Permalink

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.