什么时候应该使用HTML框架? [英] When should I use HTML frames?

查看:114
本文介绍了什么时候应该使用HTML框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说过为什么不使用HTML框架的诸多原因,从缺乏可访问性,缺乏用户体验,完全低效/不可维护,或仅仅过时。

这一切都引出了两个问题:


  1. 这种仇恨的一般共识是否也适用于iframe? li>
  2. 在您的代码中使用框架/ iframe时可以接受哪种情况?


解决方案

(1)不是固有的。内联框架有很多不受框架问题困扰的用例。无论何时您想要混合来自其他安全上下文的文档,或者没有父页面使用的脚本和样式,它们都很有用。



然而,它 可以'像使用框架一样使用iframe':将页面分割成单独的iframe区域,跨框架链接导致导航混乱,而且书签打印效果不佳,打开 - 新标签等。

(2)今天我不会使用任何框架。对于他们来说,保留大量不希望在每次导航中重新加载的页面内容的用例都是有限的。但是现在我们只是使用 XMLHttpRequest 来更新页面的一部分。



即使如此,以使得页面改变链接可访问(对于每个哈希链接使用哈希历史并且具有静态链接模拟,与真实< a> -click et al),使用 XMLHttpRequest 更新/浏览自己的页面将重新创建许多框架的导航问题,具有强烈的负面可用性,可访问性和对SEO的影响。 p>

我发现很多作者创造出华而不实的现代动画网站,通过天真地使用jQuery的 load()或类似的东西,展现古老而讨厌的框架的最坏行为。

I have heard countless reasons on why not to use HTML frames, from their lack of accessibility, the general lacking in UX, their being completely inefficient/unmaintainable, or them just being outdated.

This all brings me to two questions:

  1. Does this general consensus of hate apply to iframes as well?
  2. In what scenario(s) is it acceptable to use frames/iframes in your code?

解决方案

(1) Not inherently. iframes have many use cases that do not suffer from the problems of frames. They're useful any time you want to mix in a document from another security context, or without the scripting and styles that the parent page is using.

However, it is possible to ‘use an iframe like a frame’: to split the page up into separate iframe areas, with cross-frame-links making a navigational mess that doesn't play well with bookmarks, open-in-new-tab etc.

(2) I would not use frames for anything today. There was a limited use case for them keeping hold of large amounts of page content that you don't want to reload on each navigation. But these days we would just use XMLHttpRequest to update part of the page instead.

Even so, without care taken to make page-changing links accessible (using hash-history and having a static-link analogue for each hash-link, linked with real <a>s that response to middle-click et al), a page that updates/navigates itself using XMLHttpRequest will recreate many of the navigational problems of frames, with strongly negative usability, accessibility and SEO implications.

I find it a bit sad that many authors are creating flashy, swooshy, "modern" animated web sites that, by naïvely using jQuery's load() or similar on its own, exhibit all the worst behaviours of ancient, hated frames.

这篇关于什么时候应该使用HTML框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆