选项卡式 html 应用程序
我正在编写一个基于复杂选项卡的 Web 应用程序,其中每个选项卡彼此无关,因为没有交互。 因此,为了便于开发,我希望每个选项卡都是一个单独的 html 页面,可以单独查看,并且在后期我可以通过选项卡组装它们,也可以是菜单或树 所以问题是:
- 我打算使用 iframe,所有主流浏览器都支持它们吗?
- iframe 是否会被弃用,那么有什么替代方案,例如所有主要浏览器都支持对象标签吗?
- 也许我可以使用一些更好的策略来代替 iframe/object?
但我喜欢 iframe 的一点是它可以完全模块化,因此每个页面都不知道其他页面。
注意:我选择了解释得很好的答案,但我仍然不确定为什么不使用 iframe 问题 iframe 与 ajax 可能会回答这个问题。
I am writing a complex tab based web application where each tab is unrelated to each other in the sense that there is no interaction. So for ease of development i want I want each tab to be a separate html page viewable on its own and at later stage I can assemble them via tabs or may be menus or trees
so question or questions are:
- I am planning to use iframes, does all major browser support them?
- Are iframes going to be deprecated, so what are alternatives e.g. is object tag supported by all major browsers?
- May be i can use some better strategy instead of iframe/object?
But what I love about iframes is that it can be totally modular, so each page doesn't know about other.
Note: i selected the answer which explain well but still i am not sure why not iframes
question iframes vs ajax may answer that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
是的,所有主要桌面浏览器都支持 iframe。 许多移动浏览器也是如此,包括 iPhone 上的 IEMobile、Opera Mobile 和 Safari。 据我所知,唯一不支持 iframe 的主要浏览器是 BlackBerry 浏览器。
大多数浏览器都支持对象标签,但是各个浏览器之间的实现极其不一致。
大多数浏览器都支持对象标签,但是各个浏览器
只有一个带有普通导航菜单的平面页面有什么问题吗? 如果您一次只显示一个页面,并且放置在 iframe 之外的唯一界面元素是选项卡菜单,那么为什么不将选项卡集成到页面布局中并取消框架呢?
任何类型的框架都可能会破坏人们所使用的熟悉的浏览器行为,例如前进和后退导航按钮。 他们完全禁止使用书签。 建立网站时,您应该尽量不要限制或指示访问者如何浏览您的网站。 如果用户想要打开新选项卡的链接,则不应留下导航菜单。 如果他们将浏览器窗口设置为特定大小,则页面内容应填充该区域,而不是 iframe 尺寸指定的预定区域。
框架本质上是对用户不友好的,这也就不足为奇了,这使得它们对搜索引擎不友好; 这就是为什么很少有专业网站使用框架/iframe。 如今,廉价宽带已经足够普及,重新加载额外几千字节的导航数据对整体用户体验没有任何影响。
Yes, all major desktop browsers support iframes. So do many mobile browsers, including IEMobile, Opera Mobile, and Safari on the iPhone. The only major browser I know of that doesn't support iframes is the BlackBerry Browser.
The object tag is supported by most browsers, but the implementation is extremely inconsistent across the various browsers.
What's wrong with just having a flat page with an ordinary navigation menu? If you are only displaying one page at a time, and the only interface element being placed outside of the iframe is a tab menu, then why not just integrate the tabs into the page layout and do away with the frames?
Frames of any sort tend to break the familiar browser behaviors that people are used--like the forward and back navigation buttons. And they completely disable the use of bookmarks. When building a website, you should try not to restrict or dictate to visitors how they're allowed to browse your site. If the user wants to open a link a new tab, they should not be left without a navigation menu. If they make their browser window a particular size, the page content should fill that area, not a predetermined area specified by the dimensions of the iframe.
Frames are inherently user-unfriendly, which, unsurprisingly, makes them search-engine-unfriendly; which is why so few professional websites use frames/iframes. Cheap broadband is widespread enough these days that reloading a few extra kilobytes of navigational data makes no difference to the overall user experience.
如果我是你,我会使用 jQuery UI 选项卡 而不是我自己的解决方案。
If I were you, I would use jQuery UI Tabs instead of my own solution.
看起来你的网站不是静态的,所以我不明白你为什么用纯 HTML 来做。
我会使用 ASP.NET 和 CustomUserControl 作为每个选项卡,它们所有选项卡都是真正的独立,您可以在应用程序中的任何位置重用它们
it looks like your website is not static, so i don't see why you're doing it with bare HTML.
I'd use ASP.NET and CustomUserControl as each of your tabs, that they all the tab would be truly independent and you can reuse them anywhere in your application
对于每个选项卡中的单独页面,您也可以使用服务器包含。
For the separate pages in each tab, you can as well use server includes.
回答您的前两个问题:
所有最新的网络浏览器都支持 iframe,但我不确定移动浏览器是否支持。 Opera 移动版是的,现在不要谈论 iPhone。
html 的下一个主要迭代由 WHATWG 和 iFrame。 xhtml
也支持它,
至于不同的方法,这在很大程度上取决于什么您将使用选项卡进行操作。 如果每个选项卡上都包含大量信息或需要一段时间才能加载,那么单独的 iFrame 可能是最好的选择。 另外,如果您打算将代码作为独立页面重用,那么 iFrame 也是一个不错的选择。
To answer your first 2 questions:
iframe is supported across all the latest web browsers however i am not sure about mobile browsers. Opera mobile yes, dont now about iPhone.
the next major iteration of html is being led by WHATWG and the iFrame will be supported. It is also supported in xhtml
As far as different approaches, that very much depends on what you are going to be doing with the tabs. if each tab is going to have a lot of information on it or take a while to load then separate iFrames is probably best. Also, if you are going to reuse the code as independent pages else where then iFrames are also a good option.