为什么 html 中不推荐使用框架?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
Jakob Nielsen 在 1996 年撰写了一篇专栏,批评了框架。一些要点:
框架会阻止用户正确为页面添加书签。当加载添加书签的框架集页面时,用户之前在框架内单击鼠标并不重要。仅保存外部 URL,用户必须手动导航到原来的位置。
框架给打印网页带来了挑战。一次打印所有框架不适合不同尺寸的纸张(这样用户只能打印第一页)。用户通常必须右键单击他们想要的框架,然后选择适当的上下文菜单选项。
如果来自搜索引擎的用户位于另一个框架中,则他们可能无法访问导航元素 - 他们只会被定向到搜索引擎在其中找到文本的那个框架。
来自
虽然“框架集”(1990 年代末/2000 年代初网页上最常见的类型)正在消亡,但iframe(内联框架的缩写)仍然存在并且运行良好。事实上,最近发现 iframe 在当今的“混搭”Web 应用程序中很有用,并且目前在 HTML5 规范。
例如,Facebook 在其面向应用程序开发人员的 API 中使用它们将第三方应用程序与自己的网站无缝集成,同时最大限度地降低安全风险。 (在此模型中,所有第三方代码都保留在单独的域中,这出于安全原因是有好处的。)
Jakob Nielsen wrote a 1996 column that criticized frames. Some key points:
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.
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.
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.)
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.
不是为了回答OP,而是为了平衡框架集的攻击。</em>
我发现它们很棒,当您希望菜单完好无损时,没有什么可以与它们相媲美:
此外,您可以在获取主要内容时提供流畅的菜单动画。
合理使用,它们非常棒。
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:
Also, you can provide smooth menu-animations while fetching main contents.
Used with sense, they're super.