为什么框架在 html 中被弃用?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4263509/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 05:25:46  来源:igfitidea点击:

Why are frames deprecated in html?

htmlframes

提问by SonOfTheEARTh

HTML has had frames from early days, but they are deprecated in the latest version. Many browsers (I have tried with Internet Explorer) don't even display frames properly.

HTML 早期就有框架,但在最新版本中已弃用。许多浏览器(我曾尝试使用 Internet Explorer)甚至无法正确显示帧。

Why has this been done? What was the drawback in frames?

为什么这样做?框架的缺点是什么?

采纳答案by PleaseStand

Jakob Nielsen wrote a 1996 column that criticized frames. Some key points:

Jakob Nielsen 在 1996 年写了一篇批评框架的专栏。一些关键点:

  1. Frames prevent users from properly bookmarking pages. When a bookmarked frameset page is loaded, users' previous mouse clicks inside the frames do not matter. Only the outer URL is saved, and users have to navigate to where they were manually.

  2. Frames present challenges for printing web pages. Printing all the frames at once is not suited to the different dimensions of paper (and users can get only the first pageful that way). Users generally have to right-click the frame they want and choose the appropriate context menu option.

  3. Users coming from search engines may not have access to navigational elements if they are located in another frame — they are directed to only that frame the search engine found the text in.

  1. 框架会阻止用户正确地为页面添加书签。加载带有书签的框架集页面时,用户之前在框架内的鼠标点击无关紧要。只保存外部 URL,用户必须手动导航到他们所在的位置。

  2. 框架对打印网页提出了挑战。一次打印所有框架不适合不同尺寸的纸张(并且用户只能通过这种方式获得第一页)。用户通常必须右键单击他们想要的框架并选择适当的上下文菜单选项。

  3. 如果来自搜索引擎的用户位于另一个框架中,则他们可能无法访问导航元素——他们只会被定向到搜索引擎在其中找到文本的那个框架。

While "framesets" (the most common type used on late 1990s/early 2000s web pages) are dying, the iframe (short for inline frame) remains alive and well. In fact, recently iframes have been found useful in today's "mashup" web applications, and extensions to the iframe are currently proposed in the HTML5 specification.

虽然“框架集”(1990 年代末/ 2000 年代初网页上最常用的类型)正在消亡,但 iframe(内联框架的缩写)仍然保持活跃。事实上,最近发现 iframe 在当今的“混搭”Web 应用程序中很有用,并且目前在HTML5 规范中提出了对 iframe 的扩展。

For example, Facebook, in its API for app developers, uses them to seamlessly integrate third-party apps with their own site while minimizing the security risk. (In this model, all third-party code remains on a separate domain, which is good for security reasons.)

例如,Facebook 在其应用程序开发人员的 API 中使用它们将第三方应用程序与他们自己的网站无缝集成,同时最大限度地降低安全风险。(在此模型中,所有第三方代码都保留在单独的域中,这有利于安全。)

回答by Pascal Qyy

Frames are not deprecatedin HTML. They are obsolete in HTML 5, and just discouragedbefore this version. This has been clearly mentioned in the specified links.

HTML中不推荐使用框架。他们是在HTML 5已经过时了,只是不鼓励此版本之前。这已在指定链接中明确提及。

回答by Teson

Not to answer the OP but rather balance the bashing of framesets.

不是要回答 OP,而是要平衡对框架集的抨击。

I find them great and nothing comes close to them when you want your menu intact and still:

我发现它们很棒,当您希望菜单完好无损时,没有什么能比得上它们:

  • Visually incorporate 3-rd party pages/apps (phpmyadmin or similar)
  • Viewing doctypes other than html (pdf's or images).
  • Due to its width="x,*"you get a simple "responsive" behaviour.
  • 视觉上包含第 3 方页面/应用程序(phpmyadmin 或类似的)
  • 查看 html 以外的文档类型(pdf 或图像)。
  • 由于它的width="x,*"你得到一个简单的“响应”行为。

Also, you can provide smooth menu-animations while fetching main contents.

此外,您可以在获取主要内容的同时提供流畅的菜单动画。

Used with sense, they're super.

有意义地使用,它们是超级的。