I have an iframe on a site which takes a while to load content between pages, is there any way I can have a loading image or animated gif while the iframe is loading the next page instead of a white background?
Also I can't control the content of the pages in the iframe so can't add styles to it.
If you are controling the content of the iframe from the outer page then you could probably hide the iframe when you change the iframes src and show it again in the onload event of the iframe? You could then show anything you like whilst the iframe is hidden.
About all you can do is use one of the bazillion lightboxes out there the create an overlay, though I don't know how you'd get the trigger that the frame has fully loaded. As mentioned, cross frame scripting on other domains is not allowed (would be a serious security flaw if you could.)
Msg#: 4340509 posted 9:59 am on Jul 23, 2011 (gmt 0)
I'm coming to this late, but recall that except in ie, iframe will accept a background-image (and also a background-color), so it is quite possible to set a "loading" image/animated gif if desired. The issue would be that the background-color of the iframe content is stacked higher than the background-image, which may mean that the image is obscured quite quickly.
Unfortunately the default background for iframes in ie is #fff. This can be overcome by setting allowtransparency="true" on the iframe element, but that is proprietary and will not validate. Note the msdn documentation [msdn.microsoft.com] states that the background-color on the iframe content must also be set to transparent, but having tested in ie6-8 (not 9), that does not seem to be required.