I haven't used frames since 1998. They seem like a bad idea and in all my development I've never had a situation where frames were the right solution, or even a decent solution.
我自1998年以来就没有使用过框架。它们看起来像个坏主意,在我的所有开发中,我从未遇到过框架是正确的解决方案,甚至是一个不错的解决方案。
However, I'm now working with an internal web application written by another group and the entire site is built in a - header, left side menu, right side content - frameset.
但是,我现在正在使用由另一个组编写的内部Web应用程序,整个站点都内置在 - 标题,左侧菜单,右侧内容 - 框架集中。
For one, when VPN'd to my network I constantly get a "website.com/frames.html" cannot be found." error message. This doesn't happen when I'm on the internal network.
首先,当VPN到我的网络时,我不断找到“website.com/frames.html”找不到。“错误信息。当我在内部网络上时,这不会发生。
Second, the app has a built in email/messaging system. The number of unread messages is shown in the left side menu frame as "Messages (3)" but the count doesn't update as I read the messages. The developer told me since it was in a frame I needed to right click on the menu and 'Refresh'. Seriously????
其次,该应用程序具有内置的电子邮件/消息系统。未读消息的数量在左侧菜单框中显示为“消息(3)”,但在读取消息时计数不会更新。开发人员告诉我,因为它在一个框架中我需要右键单击菜单并“刷新”。认真????
So, my programming related question is, what reasons do you have for not using frames in a website?
所以,我的编程相关问题是,你有什么理由不在网站中使用框架?
8 个解决方案
#1
15
Although they solved a problem at the time they were created (updating part of a "page" while keeping in place a non-updating part), framesets were criticised in terms of usability pretty much from the start, as they break generic functions of the browser, such as:
虽然他们在创建时解决了一个问题(更新了“页面”的一部分,同时保留了非更新部分),但框架集从一开始就被批评了可用性,因为它们打破了通用功能。浏览器,例如:
- bookmarking, and copy-and-pasting URLs to share
- 书签,复制和粘贴要共享的URL
- printing the page as displayed on the screen
- 打印屏幕上显示的页面
- reloading the page: since the URL has generally not changed, you will often be taken back to the site's homepage or default frameset; manually reloading some frames is possible, but not obvious to the user
- 重新加载页面:由于URL一般没有更改,您将经常被带回网站的主页或默认框架集;手动重新加载一些帧是可能的,但对用户来说并不明显
- back and forward buttons are ambiguous: undo/redo the last frame change, or take you to the last time the URL bar changed?
- 后退和前进按钮是不明确的:撤消/重做最后一帧更改,或带您到最后一次更改URL栏?
The heaviest burden of avoiding framesets - including the same content on every page - is trivial to solve if you are using any server-side language to generate your HTML, even if all it provides is a "server side include". Unlike framesets, a server-side include could occur anywhere on the page; building a site with a server-side scripting language or templating system has other obvious advantages too.
如果您使用任何服务器端语言生成HTML,即使它提供的所有内容都是“服务器端包含”,那么避免使用框架集(包括每页上相同内容)的最沉重负担也是微不足道的。与框架集不同,服务器端包含可能出现在页面的任何位置;使用服务器端脚本语言或模板系统构建站点也有其他明显的优势。
There is still an advantage to being able to update small areas of the page without reloading the entire content, which can be achieved via AJAX. This sometimes leads people to create interfaces with all the problems of framesets outlined above, but that is hardly an argument in favour of framesets. Again, a site built with well-designed AJAX functionality can achieve things which framesets don't even begin to address.
能够在不重新加载整个内容的情况下更新页面的小区域仍然是一个优点,这可以通过AJAX实现。这有时会导致人们创建与上面概述的框架集的所有问题的接口,但这不是支持框架集的论据。同样,使用精心设计的AJAX功能构建的站点可以实现框架集甚至无法解决的问题。
#2
10
One good reason to avoid frames today is they have been deprecated in HTML 5: Chapter 11 Obsolete features
今天避免使用框架的一个很好的理由是它们已经在HTML 5中被弃用:第11章过时的功能
11.2 Non-conforming features
11.2不符合要求的特征
Elements in the following list are entirely obsolete, and must not be used by authors:
以下列表中的元素完全过时,作者不得使用:
[...]
[...]
frame
帧
frameset
框架
noframes
无框架
Either use iframe and CSS instead, or use server-side includes to generate complete pages with the various invariant parts merged in.
要么使用iframe和CSS,要么使用服务器端包含来生成包含各种不变部分的完整页面。
#3
8
The #1 reason? Users hate them.
#1的原因?用户讨厌他们。
Even if they offered advantages in other areas (separation of code, application design, speed etc) they are part of the user interface. If users don't approve, don't use them.
即使它们在其他领域(代码分离,应用程序设计,速度等)提供了优势,它们也是用户界面的一部分。如果用户不批准,请不要使用它们。
#4
7
Frames were vaguely useful when you had a static web site, to avoid repeating navigation menu in all pages, for example. It also reduced the overall size of a page.
例如,当您拥有静态网站时,框架非常有用,以避免在所有页面中重复导航菜单。它还减少了页面的整体大小。
Both these arguments are obsolete now: sites don't hesitate to serve fat pages, and most of them are dynamically built so including such navigational parts (or status, etc.) has no problem.
这两个论点现在已经过时了:网站毫不犹豫地为胖页面提供服务,而且大多数都是动态构建的,所以包括这些导航部分(或状态等)都没有问题。
The "why" part is well answered above, partly by your own question (you hit a limitation, although it can be overridden with a bit of JS).
“为什么”部分在上面得到了很好的回答,部分是由你自己的问题(你遇到了一个限制,虽然它可以被一些JS覆盖)。
#5
6
My number 1 reason not to use frames is because they break the bookmark (aka favorite) feature of browsers.
我不使用框架的第一个原因是因为它们破坏了浏览器的书签(也就是最喜欢的)功能。
With the technology that exists today, frames have become obsolete. But if your legacy project still uses them, you can make the messages update with some ajax.
凭借当今存在的技术,框架已经过时。但是,如果您的遗留项目仍然使用它们,您可以使用某些ajax更新消息。
#6
4
Just because of the cell phone iPad craze doesn't mean that highly functional full featured sites are suddenly "obsolete", and those who decided to make framesets obsolete seem to be the same complainers who never figured out their full potential in the first place, or maybe they're the lobbyists of the mega-corporate cell-phone and tablet makers who couldn't be bothered to make a decent frames capable browser for their itty-bitty screens.
仅仅因为手机iPad的热潮并不意味着功能强大的全功能网站突然“过时”,那些决定制作框架集的人似乎也是同样的抱怨者,他们从来没有发现他们的全部潜力,或许他们是大型企业手机和平板电脑制造商的游说者,他们无法为他们的网络屏幕制作一个体面的框架浏览器。
Admittedly, iFrames can handle simple jobs like scrolling and/or displaying independent segments within a single page pretty well, and I use them for that inside my own frames based website, but to get them to work as well as the foundation for a site itself is a nightmare. Trust me, I know because my website is one of the most sophisticated frameset based sites on the Internet and I've been looking at the pros and cons of transposing it all to iFrames. Nightmare is an understatement.
不可否认,iFrames可以处理简单的工作,例如滚动和/或在单个页面中显示独立的段,并且我在我自己的基于框架的网站中使用它们,但是为了让它们工作以及网站本身的基础是一场噩梦。相信我,我知道,因为我的网站是互联网上最复杂的基于框架集的网站之一,我一直在寻找将它全部转移到iFrames的优点和缺点。梦魇是轻描淡写的。
I can already hear the whiners saying, "Well why did you build it that way in the first place then?" ... and the answer is A: Because I'm not lazy. and B: Because a frames based site is the most functional, visually appealing, and user friendly format for an information based site with hundreds of pages of content that doesn't have to rely on a server. By that I mean all but the external advertising can be viewed straight off a flash drive. No MySQL or PHP needed.
我已经可以听到抱怨者说:“那你为什么一开始就这样建造呢?” ......答案是答:因为我不懒惰。和B:因为基于帧的站点是具有数百页内容而不必依赖服务器的基于信息的站点的功能最强,视觉上吸引人且用户友好的格式。我的意思是除了外部广告之外的所有广告都可以直接通过闪存驱动器查看。不需要MySQL或PHP。
Here's some of the issues I've encountered:
这是我遇到的一些问题:
- The objection to orphaned pages can be easily handled with JavaScript.
- 可以使用JavaScript轻松处理对孤立页面的异议。
- The objection regarding bookmarking is irrelevant unless you use no frames all.
- 除非您不使用任何帧,否则关于书签的异议是无关紧要的。
- Content specific bookmarking can be handled with an "Add Bookmark" JavaScript function
- 可以使用“添加书签”JavaScript功能处理特定于内容的书签
- The objection regarding SEO is easily handled by an XML sitemap and JavaScript.
- 有关SEO的异议很容易通过XML站点地图和JavaScript来处理。
- Laying out dynamically sized frames is far easier and more dependable with standard framesets.
- 使用标准框架集布置动态大小的框架更容易,更可靠。
- Targeting and replacing nested framesets from an external frame is easier with standard framesets.
- 使用标准框架集可以更轻松地从外部框架中定位和替换嵌套框架集。
- In-house scripts like JavaScript searches and non-server dependent shopping carts that are too complex for cookies don't seem possible with iFrames, or if they are, it's way more hassle to get them working than using standard frames.
- 内部脚本(如JavaScript搜索和非服务器相关的购物车)对于使用iFrames而言似乎不太可能存在,或者如果是这样的话,使用它们比使用标准帧更麻烦。
All that being said, I like the single page appeal of iFrames, and when they can actually do all the same stuff for my site as easily as standard frames does now, then I'll migrate. In the meantime, this nonsense about them being "obsolete" is as irksome as the other so-called "upgrades" they've foisted on us over the years without thinking it all the way through.
话虽如此,我喜欢iFrames的单页吸引力,当他们真正为我的网站做所有相同的东西时,就像标准框架一样容易,然后我会迁移。与此同时,关于它们“过时”的这种废话与其他所谓的“升级”一样令人厌烦,它们多年来一直强加给我们而没有一直考虑到它。
So what does all this boil down to for the question of whether or not to use framesets? The answer is that it all depends on what you want your site to do and on what platform it will mostly be viewed on. At some point it becomes impractical to make a multi-page site work well without some frames or iFrame integration. However if you're just creating a basic profile page that displays well on a cell phone or tablet, don't bother with framesets.
那么对于是否使用框架集的问题,所有这些归结为什么呢?答案是,这一切都取决于您希望您的网站做什么,以及它将在哪个平台上进行查看。在某些时候,如果没有一些框架或iFrame集成,使多页面网站工作得很好是不切实际的。但是,如果您只是创建一个在手机或平板电脑上显示良好的基本配置文件页面,请不要打扰框架集。
#7
2
They almost always make people angry. What more do you need?
他们几乎总是让人生气。你还需要什么?
#8
1
Frames are really useful in some occasions. If you are creating a local webpage that serves only for reading, no interactivity involved and the website will not be public on the internet, all the reasons on not to use frames are removed. For example a user manual for an application that is developed solely in html, frames are really useful in keeping a table of contents on the left in a simple and easy to code way. Also if you have proper navigation within the website then the back button ambiguity is removed completely
框架在某些场合非常有用。如果您要创建仅供阅读的本地网页,不涉及交互,并且网站不会在互联网上公开,则不会删除所有不使用框架的原因。例如,仅使用html开发的应用程序的用户手册,框架对于以简单且易于编码的方式保持左侧的目录非常有用。此外,如果您在网站内有适当的导航,则完全删除后退按钮歧义
#1
15
Although they solved a problem at the time they were created (updating part of a "page" while keeping in place a non-updating part), framesets were criticised in terms of usability pretty much from the start, as they break generic functions of the browser, such as:
虽然他们在创建时解决了一个问题(更新了“页面”的一部分,同时保留了非更新部分),但框架集从一开始就被批评了可用性,因为它们打破了通用功能。浏览器,例如:
- bookmarking, and copy-and-pasting URLs to share
- 书签,复制和粘贴要共享的URL
- printing the page as displayed on the screen
- 打印屏幕上显示的页面
- reloading the page: since the URL has generally not changed, you will often be taken back to the site's homepage or default frameset; manually reloading some frames is possible, but not obvious to the user
- 重新加载页面:由于URL一般没有更改,您将经常被带回网站的主页或默认框架集;手动重新加载一些帧是可能的,但对用户来说并不明显
- back and forward buttons are ambiguous: undo/redo the last frame change, or take you to the last time the URL bar changed?
- 后退和前进按钮是不明确的:撤消/重做最后一帧更改,或带您到最后一次更改URL栏?
The heaviest burden of avoiding framesets - including the same content on every page - is trivial to solve if you are using any server-side language to generate your HTML, even if all it provides is a "server side include". Unlike framesets, a server-side include could occur anywhere on the page; building a site with a server-side scripting language or templating system has other obvious advantages too.
如果您使用任何服务器端语言生成HTML,即使它提供的所有内容都是“服务器端包含”,那么避免使用框架集(包括每页上相同内容)的最沉重负担也是微不足道的。与框架集不同,服务器端包含可能出现在页面的任何位置;使用服务器端脚本语言或模板系统构建站点也有其他明显的优势。
There is still an advantage to being able to update small areas of the page without reloading the entire content, which can be achieved via AJAX. This sometimes leads people to create interfaces with all the problems of framesets outlined above, but that is hardly an argument in favour of framesets. Again, a site built with well-designed AJAX functionality can achieve things which framesets don't even begin to address.
能够在不重新加载整个内容的情况下更新页面的小区域仍然是一个优点,这可以通过AJAX实现。这有时会导致人们创建与上面概述的框架集的所有问题的接口,但这不是支持框架集的论据。同样,使用精心设计的AJAX功能构建的站点可以实现框架集甚至无法解决的问题。
#2
10
One good reason to avoid frames today is they have been deprecated in HTML 5: Chapter 11 Obsolete features
今天避免使用框架的一个很好的理由是它们已经在HTML 5中被弃用:第11章过时的功能
11.2 Non-conforming features
11.2不符合要求的特征
Elements in the following list are entirely obsolete, and must not be used by authors:
以下列表中的元素完全过时,作者不得使用:
[...]
[...]
frame
帧
frameset
框架
noframes
无框架
Either use iframe and CSS instead, or use server-side includes to generate complete pages with the various invariant parts merged in.
要么使用iframe和CSS,要么使用服务器端包含来生成包含各种不变部分的完整页面。
#3
8
The #1 reason? Users hate them.
#1的原因?用户讨厌他们。
Even if they offered advantages in other areas (separation of code, application design, speed etc) they are part of the user interface. If users don't approve, don't use them.
即使它们在其他领域(代码分离,应用程序设计,速度等)提供了优势,它们也是用户界面的一部分。如果用户不批准,请不要使用它们。
#4
7
Frames were vaguely useful when you had a static web site, to avoid repeating navigation menu in all pages, for example. It also reduced the overall size of a page.
例如,当您拥有静态网站时,框架非常有用,以避免在所有页面中重复导航菜单。它还减少了页面的整体大小。
Both these arguments are obsolete now: sites don't hesitate to serve fat pages, and most of them are dynamically built so including such navigational parts (or status, etc.) has no problem.
这两个论点现在已经过时了:网站毫不犹豫地为胖页面提供服务,而且大多数都是动态构建的,所以包括这些导航部分(或状态等)都没有问题。
The "why" part is well answered above, partly by your own question (you hit a limitation, although it can be overridden with a bit of JS).
“为什么”部分在上面得到了很好的回答,部分是由你自己的问题(你遇到了一个限制,虽然它可以被一些JS覆盖)。
#5
6
My number 1 reason not to use frames is because they break the bookmark (aka favorite) feature of browsers.
我不使用框架的第一个原因是因为它们破坏了浏览器的书签(也就是最喜欢的)功能。
With the technology that exists today, frames have become obsolete. But if your legacy project still uses them, you can make the messages update with some ajax.
凭借当今存在的技术,框架已经过时。但是,如果您的遗留项目仍然使用它们,您可以使用某些ajax更新消息。
#6
4
Just because of the cell phone iPad craze doesn't mean that highly functional full featured sites are suddenly "obsolete", and those who decided to make framesets obsolete seem to be the same complainers who never figured out their full potential in the first place, or maybe they're the lobbyists of the mega-corporate cell-phone and tablet makers who couldn't be bothered to make a decent frames capable browser for their itty-bitty screens.
仅仅因为手机iPad的热潮并不意味着功能强大的全功能网站突然“过时”,那些决定制作框架集的人似乎也是同样的抱怨者,他们从来没有发现他们的全部潜力,或许他们是大型企业手机和平板电脑制造商的游说者,他们无法为他们的网络屏幕制作一个体面的框架浏览器。
Admittedly, iFrames can handle simple jobs like scrolling and/or displaying independent segments within a single page pretty well, and I use them for that inside my own frames based website, but to get them to work as well as the foundation for a site itself is a nightmare. Trust me, I know because my website is one of the most sophisticated frameset based sites on the Internet and I've been looking at the pros and cons of transposing it all to iFrames. Nightmare is an understatement.
不可否认,iFrames可以处理简单的工作,例如滚动和/或在单个页面中显示独立的段,并且我在我自己的基于框架的网站中使用它们,但是为了让它们工作以及网站本身的基础是一场噩梦。相信我,我知道,因为我的网站是互联网上最复杂的基于框架集的网站之一,我一直在寻找将它全部转移到iFrames的优点和缺点。梦魇是轻描淡写的。
I can already hear the whiners saying, "Well why did you build it that way in the first place then?" ... and the answer is A: Because I'm not lazy. and B: Because a frames based site is the most functional, visually appealing, and user friendly format for an information based site with hundreds of pages of content that doesn't have to rely on a server. By that I mean all but the external advertising can be viewed straight off a flash drive. No MySQL or PHP needed.
我已经可以听到抱怨者说:“那你为什么一开始就这样建造呢?” ......答案是答:因为我不懒惰。和B:因为基于帧的站点是具有数百页内容而不必依赖服务器的基于信息的站点的功能最强,视觉上吸引人且用户友好的格式。我的意思是除了外部广告之外的所有广告都可以直接通过闪存驱动器查看。不需要MySQL或PHP。
Here's some of the issues I've encountered:
这是我遇到的一些问题:
- The objection to orphaned pages can be easily handled with JavaScript.
- 可以使用JavaScript轻松处理对孤立页面的异议。
- The objection regarding bookmarking is irrelevant unless you use no frames all.
- 除非您不使用任何帧,否则关于书签的异议是无关紧要的。
- Content specific bookmarking can be handled with an "Add Bookmark" JavaScript function
- 可以使用“添加书签”JavaScript功能处理特定于内容的书签
- The objection regarding SEO is easily handled by an XML sitemap and JavaScript.
- 有关SEO的异议很容易通过XML站点地图和JavaScript来处理。
- Laying out dynamically sized frames is far easier and more dependable with standard framesets.
- 使用标准框架集布置动态大小的框架更容易,更可靠。
- Targeting and replacing nested framesets from an external frame is easier with standard framesets.
- 使用标准框架集可以更轻松地从外部框架中定位和替换嵌套框架集。
- In-house scripts like JavaScript searches and non-server dependent shopping carts that are too complex for cookies don't seem possible with iFrames, or if they are, it's way more hassle to get them working than using standard frames.
- 内部脚本(如JavaScript搜索和非服务器相关的购物车)对于使用iFrames而言似乎不太可能存在,或者如果是这样的话,使用它们比使用标准帧更麻烦。
All that being said, I like the single page appeal of iFrames, and when they can actually do all the same stuff for my site as easily as standard frames does now, then I'll migrate. In the meantime, this nonsense about them being "obsolete" is as irksome as the other so-called "upgrades" they've foisted on us over the years without thinking it all the way through.
话虽如此,我喜欢iFrames的单页吸引力,当他们真正为我的网站做所有相同的东西时,就像标准框架一样容易,然后我会迁移。与此同时,关于它们“过时”的这种废话与其他所谓的“升级”一样令人厌烦,它们多年来一直强加给我们而没有一直考虑到它。
So what does all this boil down to for the question of whether or not to use framesets? The answer is that it all depends on what you want your site to do and on what platform it will mostly be viewed on. At some point it becomes impractical to make a multi-page site work well without some frames or iFrame integration. However if you're just creating a basic profile page that displays well on a cell phone or tablet, don't bother with framesets.
那么对于是否使用框架集的问题,所有这些归结为什么呢?答案是,这一切都取决于您希望您的网站做什么,以及它将在哪个平台上进行查看。在某些时候,如果没有一些框架或iFrame集成,使多页面网站工作得很好是不切实际的。但是,如果您只是创建一个在手机或平板电脑上显示良好的基本配置文件页面,请不要打扰框架集。
#7
2
They almost always make people angry. What more do you need?
他们几乎总是让人生气。你还需要什么?
#8
1
Frames are really useful in some occasions. If you are creating a local webpage that serves only for reading, no interactivity involved and the website will not be public on the internet, all the reasons on not to use frames are removed. For example a user manual for an application that is developed solely in html, frames are really useful in keeping a table of contents on the left in a simple and easy to code way. Also if you have proper navigation within the website then the back button ambiguity is removed completely
框架在某些场合非常有用。如果您要创建仅供阅读的本地网页,不涉及交互,并且网站不会在互联网上公开,则不会删除所有不使用框架的原因。例如,仅使用html开发的应用程序的用户手册,框架对于以简单且易于编码的方式保持左侧的目录非常有用。此外,如果您在网站内有适当的导航,则完全删除后退按钮歧义