简体   繁体   English

不使用iframe将一个网站嵌入另一个网站有什么好处?

[英]What are the benefits of not using an iframe to embed one site in another?

I was studying how Disqus and other embedded wigets are implemented, and I came to realize that they don't use an enclosing iframe where all their widget is run. 我当时研究了Disqus和其他嵌入式Wigets的实现方式,后来我意识到他们没有在运行所有小部件的封闭iframe中使用它们。 What they do is to append elements dynamically to the embedding page through JavaScipt and then run almost every form or button in some iframe. 他们要做的是通过JavaScipt将元素动态地附加到嵌入页面,然后在某个iframe中运行几乎所有表单或按钮。 What's the point of doing this? 这样做有什么意义? Couldn't they just wrap everything in an iframe and then change the parent window URL (to allow navigation) through some kind of cross-domain messaging system such as easyXDM? 他们难道不能只是将所有内容包装在iframe中,然后通过某种跨域消息传递系统(例如easyXDM)更改父窗口URL(以允许导航)吗? Can anybody point out some benefits that arise from having some elements not inside an iframe? 有人能指出由于某些元素不在iframe内而带来的好处吗?

  1. Code inside an iframe may not be able to set cookies as browser thinks it is an advertisement. iframe中的代码可能无法设置cookie,因为浏览器认为它是广告。

  2. Iframe content cannot control the size of the outside iframe, so iframe needs to be created with javascript and javascript needs to be loaded externally so that external site has total over iframe size. iframe内容无法控制外部iframe的大小,因此需要使用javascript创建iframe,并且需要从外部加载javascript,以便外部网站的总大小超过iframe。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM