|IFRAME - Is It Safe Yet?|
Should I use IFRAME, or is there an acceptable alternative?
I have a project where I need to load formatted HTML into a srollable TEXTAREA-type window.
IFRAME is suitable for the job, but is there something else I can substitute that may not have the legacy issues that an IFRAME may have?
How safe is it to use IFRAME in 2004 compared to the past?
We'll be using this window as an integral part of our project (as a way of proving a scrollable, clickable list, utilizing different styles).
Again... Is it safe?
You may run into legacy issues. You can use CSS and the DIV tag. Position the DIV where you want and set the overflow property to scroll. There are legacy issues with this approach too. Frankly I think you'll have better luck with an IFrame as the majority of browsers in use today do support it. Your problem will mostly be with browsers earlier than 4.x except for NS which didn't start supporting IFRAMES until somewhere in version 6.x.
Do older browsers properly support <noframes>? If so, just use the iframe, with a link to a popup window or something in the <noframes> content.
|Position the DIV where you want and set the overflow property to scroll. There are legacy issues with this approach too. |
There are a lot more than legacy issues, there are IE 6 issues which can be pretty serious from a useability point of view.
You can use an iframe but it will only work in modern browsers, specifically it won't work in Netscape 4x or earlier, or IE 3 or earlier if I remember right. That can be 1-2% of your site visitors so the decision is up to you.
An option is to use the equivalent noframe space in the iframe, like this:
content of your webpage here, only will be seen by non-iframe supporting browsers.
That way almost all browsers, except some handhelds, that simply don't support frames at all in any form, will be able to view it.
Yes, iframe is pretty safe, with three caveats, some, none or all of which may apply in your situation.
First, browser support. Every modern graphical browser handles iframes. The only problem is with Netscape 4, but you may not be supporting that anyway (if this is a new project, don't bother).
Third is accessibility. Using any kind of frame makes it much harder if not impossible for users with screenreaders, and keyboard navigation is affected too. It depends on the kind of site you have whether the disadvantages can be reduced by some kind of backup approach.
Scrolling divs are lovely and solve the accessibility issues, but as isitreal says, there are some serious hurdles to overcome in IE5+ which make it a less tempting option.
What are the IE5 scrolling div issues? I have used this approach a few times recently.
|there are some serious hurdles to overcome in IE5+ which make it a less tempting option |
I found that IE 5.5 had virtually flawless overflow:auto support, as close to perfect as you can get, equalled only by Firefox > .8 [or .7?], but somehow the IE team managed to break this almost perfect support somewhere between IE 5.5 and 6. [this being I assume largely the same team who is supposed to magically 'fix' IE, what a joke...]. As for mac browsers, forget it.
Also, opera only had partial support as of 7, and as of 7.5 it still requires a physical click in the scrolling space before you can scroll it with your mousewheel. I'm not sure if this is a bug or was deliberate, either way it makes the feature unuseable for standard users. The IE 6 bug is however not trivial, and totally breaks scrolling in a way that is as far as I've found absolutely not fixable.
After years of waiting for a real substitute for frames/iframes I finally had to admit that as far as reality was concerned, overflow:auto wasn't going to happen on a commercial level.
Pay special attention to the search engine issues encylo mentions, those are not trivial, especially if more than one page is going to be loaded in that iframe. I've solved that problem on my own sites, but it's very complex to get it working correctly crossbrowser, and I'd strongly recommend against bringing the search engines into the iframe at all.
As to accessibility, Encyclo has that one exactly right too, I'd not paid attention to that issue, but when I looked at iframes/frames in handheld emulators, I was pretty shocked to see a big nothing there even though I used full noframes type options, that's when I decided tedster was pretty much right about not using this stuff except where no other good solution exists, and there are those cases, I've just been doing a big site where we use both frames and iframes for certain components and they are definitely by far the best solution to the problem for that specific application, bringing in data in a scrolling format.
|What are the IE5 scrolling div issues? I have used this approach a few times recently. |
No IE 5.5 issues, partial support for IE 5.0, IE 6 big problems. Any blank space in the scrolling area breaks the scroll, user has no way to figure out why it's not scrolling so assumes page is broken and leaves. My last big project I did using only scrolling divs for site layout I got reports that in other IE 6's there was no scrolling happening at all, I was never able to duplicate that full failure, but I believe the person who reported it.
Just to add a problem/feature of Internet Explorer 6 Frames/iframes and Session cookies. Cookies are not passed unless the child content has a P3P compact policy header. KBA 323752
Does that apply even if you set the domain on the cookie explicitly? Good information in any case, thanks.
<IFRAME SRC="page.html">Info for browsers that don't support iframes.</IFRAME>
I was looking for a workaround for those who had browsers that didn't support the IFRAME tag (without having to use a browser sniffer).
Thanks a bunch!