Are IFrames (HTML) obsolete? [closed]

2019-01-04 09:53发布

Getting contradictory messages about that, hope they're not. I cannot imagine support for it would stop, since a gazillion sites use them.

Some additional questions about that:

  1. Why should they phase out this tag?
  2. Any alternative for it?

14条回答
2楼-- · 2019-01-04 10:31

At my previous company, we provided a hosted application that customers would integrate into their own websites. At times, they would use an IFrame to do this, fitting our hosted page into their existing designs. Sometimes this was even done seamlessly (ie. the IFrame had no borders or scrollbars, it just looked like part of the page). I considered this to be a good use of the tag.

查看更多
混吃等死
3楼-- · 2019-01-04 10:36

Compliance and Security issues can also drive you to use Iframes; Shopping carts are popular IFrame-based implementations when you want to visually incorporate a shopping cart as part of some web pages without taking on full responsibility for the payment processing side of things.

We commonly deliver an Iframe to integrate our eCommerce stuff and clients like how turnkey it can be.

查看更多
【Aperson】
4楼-- · 2019-01-04 10:39

Iframes are obsolete for page layout. Never use them instead of good CSS layout, even table-based layout is better.

Good reasons for using iframes are:

  • ads: adwords for example uses this technique, it is good for encapsulating - ad css won't destroy your page.
  • hidden iframe: it can be used for hundreds usable things, like tracking, ajax-alternative, etc.
查看更多
ら.Afraid
5楼-- · 2019-01-04 10:41

Support for <iframe> is still there in HTML 5, so I don't think this will change in the near future.

To answer your other questions:

  1. <iframe>s (as frames in general) are most of the time not user-friendly:
    • They don't allow easy access of the content in the frame via an URL (without losing the content outside of the frame at least).
    • Most "technophobe" users are irritated by frames.
    • As far as I know they are slower to render for browsers
  2. Alternatives include dynamic page generation (SSI, PHP, Rails and so on) and using JavaScript / AJAX to change contents of e.g. a <div>

To be clear: I'm talking about <iframe> as an interface element. Not a hidden element for loading other stuff like e.g. Google Mail does.

查看更多
萌系小妹纸
6楼-- · 2019-01-04 10:41

IFrames are used a lot with AJAX. GMail for example, uses nine hidden IFrames I believe.

查看更多
叼着烟拽天下
7楼-- · 2019-01-04 10:42

In my opinion the W3C jumped the gun in dumping iframes from the Strict HTML and XHTML doctypes. In theory you would use the <object> element to add foreign objects to your document, but browser differences and limitations have made this a nonstarter for many developers. With the much-more-pragmatic HTML 5 (which is still a draft), iframes are back and even have two new attributes: seamless, and the intriguing sandbox.

查看更多
登录 后发表回答