在布局中使用 iframe?
我真的想要一种方法来拥有一个文件,例如导航栏和页脚,这样我就不必浏览所有页面(只有 20 个左右,但无论如何......)来更新它。所以我意识到框架(iframe?有什么区别)可以帮助我解决这个问题。
此外,我听说很多地方由于某种原因框架在网页设计中是禁忌。这与 SEO 有关吗?
我可以安全地使用 (i) 框架吗?是否有保留网址 http://www.domain.tld/pagename.html 的替代方法?
I really want a way to have one single file for, for example, the navigation bar and the footer so that I don't have to go through all of my pages (only 20 or so, but anyway...) to update it. So I've realized that frames (iframes? What's the difference) can help me with this.
Additionally, I've heard a lot of places that frames are a no-go in web design for some reason. Is this to do with SEO?
Can I use (i)frames safely? Are there alternatives that keep the url http://www.domain.tld/pagename.html ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
无论您做什么,都不要使用框架/iframe 进行页面布局。
最好的选择是使用服务器端脚本语言来构建页面。这样,您可以将各个组件放在单独的文件中(这使得维护变得容易),然后使用脚本语言组合它们。
Whatever you do, don't use frames/iframes for page layout.
Your best bet is to use a server-side scripting language to build your page. That way, you can have the individual components in separate files (which makes maintenance easy) and then compose them using the scripting language.
iframe 将文档嵌入到页面中间。
框架是框架集的一部分,框架集由整个页面组成。
它们可以,但有很多缺点(搞乱链接、打印、导致滚动问题等)。使用包含(例如 php 或 ssi)或模板系统(例如模板工具包的ttree) 代替。
An iframe embeds a document in the middle of a page.
A frame is part of a frameset, which consists of an entire page.
They could, but have plenty of drawbacks (mucking up linking, printing, causing scrolling issues, etc). Use an include (e.g. php or ssi) or template system (e.g. template toolkit's ttree) instead.
添加到这些 两个很好的答案,来自从 SEO 的角度来看,基于框架的网站也可能是一个坏主意。
请参阅此内容
作为旁注,你考虑过301重定向吗?它并不完全保留相同的地址,而是相反,但如果我理解您的担忧,这可能就是您想要的。
Adding to these two good answers, from the SEO point of view a frame based site is also might be a bad idea.
See this
As a side note, have yo considered 301 redirect? It is not precisely keeping the same address, rather the opposite but it might be what you want if I understood your concern.