为什么 html 中不推荐使用框架?

发布于 2024-10-04 11:35:27 字数 96 浏览 5 评论 0原文

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

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

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.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

迷爱 2024-10-11 11:35:27

Jakob Nielsen 在 1996 年撰写了一篇专栏,批评了框架。一些要点:

  1. 框架会阻止用户正确为页面添加书签。当加载添加书签的框架集页面时,用户之前在框架内单击鼠标并不重要。仅保存外部 URL,用户必须手动导航到原来的位置。

  2. 框架给打印网页带来了挑战。一次打印所有框架不适合不同尺寸的纸张(这样用户只能打印第一页)。用户通常必须右键单击他们想要的框架,然后选择适当的上下文菜单选项。

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

    来自

虽然“框架集”(1990 年代末/2000 年代初网页上最常见的类型)正在消亡,但iframe(内联框架的缩写)仍然存在并且运行良好。事实上,最近发现 iframe 在当今的“混搭”Web 应用程序中很有用,并且目前在 HTML5 规范

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

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

  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.

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.

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.)

情绪操控生活 2024-10-11 11:35:27

HTML 中的框架并未弃用。它们在 HTML 5 中已过时,并且只是 不鼓励在此版本之前。这已在指定链接中明确提及。

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

椒妓 2024-10-11 11:35:27

不是为了回答OP,而是为了平衡框架集的攻击。<​​/em>

我发现它们很棒,当您希望菜单完好无损时,没有什么可以与它们相媲美:

  • 直观地合并第3方页面/应用程序(phpmyadmin或类似)
  • 查看 html 以外的文档类型(pdf 或图像)。
  • 由于它的 width="x,*" 你会得到一个简单的“响应式”行为。

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

合理使用,它们非常棒。

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

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.

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

Used with sense, they're super.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文