• <small id='whpI3'></small><noframes id='whpI3'>

    <legend id='whpI3'><style id='whpI3'><dir id='whpI3'><q id='whpI3'></q></dir></style></legend>
    • <bdo id='whpI3'></bdo><ul id='whpI3'></ul>
    <i id='whpI3'><tr id='whpI3'><dt id='whpI3'><q id='whpI3'><span id='whpI3'><b id='whpI3'><form id='whpI3'><ins id='whpI3'></ins><ul id='whpI3'></ul><sub id='whpI3'></sub></form><legend id='whpI3'></legend><bdo id='whpI3'><pre id='whpI3'><center id='whpI3'></center></pre></bdo></b><th id='whpI3'></th></span></q></dt></tr></i><div id='whpI3'><tfoot id='whpI3'></tfoot><dl id='whpI3'><fieldset id='whpI3'></fieldset></dl></div>
    <tfoot id='whpI3'></tfoot>

        JSONP 与 IFrame?

        JSONP vs IFrame?(JSONP 与 IFrame?)
      1. <legend id='vvx37'><style id='vvx37'><dir id='vvx37'><q id='vvx37'></q></dir></style></legend>

        <small id='vvx37'></small><noframes id='vvx37'>

            <tbody id='vvx37'></tbody>

                <tfoot id='vvx37'></tfoot>
                  <bdo id='vvx37'></bdo><ul id='vvx37'></ul>
                  <i id='vvx37'><tr id='vvx37'><dt id='vvx37'><q id='vvx37'><span id='vvx37'><b id='vvx37'><form id='vvx37'><ins id='vvx37'></ins><ul id='vvx37'></ul><sub id='vvx37'></sub></form><legend id='vvx37'></legend><bdo id='vvx37'><pre id='vvx37'><center id='vvx37'></center></pre></bdo></b><th id='vvx37'></th></span></q></dt></tr></i><div id='vvx37'><tfoot id='vvx37'></tfoot><dl id='vvx37'><fieldset id='vvx37'></fieldset></dl></div>
                • 本文介绍了JSONP 与 IFrame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  很快我将需要构建一个小部件,我们的一些客户可以将其嵌入到他们自己的网站中.

                  Soon I'll be needing to build a widget that some of our clients can embed in their own websites.

                  为了将来证明我的小部件,嵌入代码将是这样的:

                  To future proof my widget the embed code would be something like this:

                  <script type="text/javascript" src="path/to/remote/file.js"></script>
                  <div id="my_widget"></div>
                  

                  iframe 与 JSONP 的优缺点是什么?

                  What are the strengths and weaknesses of iframes vs JSONP?

                  iframe 是否存在任何常见的基于 SEO 的问题?

                  Are there any common SEO based issues with iframes?

                  推荐答案

                  首先,iframe和jsonp并不是互斥的:一个是渲染手段,一个是通信手段.

                  First of all, iframes and jsonp are not mutually exclusive: one is a rendering mean, the other is a communication mean.

                  您的选择是在文档内包含(即在宿主 DOM 中创建小部件)或 iframe 内包含(即为小部件拥有一个新的、单独的 DOM)之间.

                  Your choice is rather between in-document inclusion (that is creating the widget within the host DOM) or in-iframe inclusion (that is having a new, separate DOM for the widget).

                  iframe 的优势在于沙盒:您的小部件与主机的 javascript 和 css 之间不会发生冲突.这意味着您可以安全地:

                  The advantage of an iframe is sandboxing: no collision between your widget and the host's javascript and css. That means you can safely:

                  • 使用/定义任何你想要的 javascript 库
                  • 使用简单的 html 代码和简单的 css 规则(这对维护来说是一个明显的好处)

                  至于缺点:

                  • iframe 很重,可能会严重减慢主机页面的渲染速度
                  • iframe 也会消耗更多的内存和资源,如果主机页面针对移动设备,这可能是个问题

                  因此,如果可以合理地假设使用您的小部件的人愿意为此调整"他们的页面,请采用文档内方式.如果没有,请使用 iframe,但要了解限制.

                  So, if it is reasonable to assume people using your widget will be willing to "adapt" their pages for it, go the in-document way. If not, use an iframe but understand the limits.

                  对于 SEO 问题,只要您动态创建小部件(无论是在文档内还是使用 iframe),搜索引擎都不会看到它.我不知道这是否是你想要的,但这就是你会得到的;)

                  As for SEO issues, as long as you dynamically create the widget (whether it's in-document or with an iframe), search engines won't see it. I dunno if that's what you want, but that's what you'll get ;)

                  这篇关于JSONP 与 IFrame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  Embed YouTube video - Refused to display in a frame because it set #39;X-Frame-Options#39; to #39;SAMEORIGIN#39;(嵌入 YouTube 视频 - 拒绝显示在框架中,因为它将“X-Frame-Options设置为“SAMEORIGIN)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)

                    <tbody id='pn3YM'></tbody>

                  • <legend id='pn3YM'><style id='pn3YM'><dir id='pn3YM'><q id='pn3YM'></q></dir></style></legend>
                      <bdo id='pn3YM'></bdo><ul id='pn3YM'></ul>

                        <tfoot id='pn3YM'></tfoot>
                        <i id='pn3YM'><tr id='pn3YM'><dt id='pn3YM'><q id='pn3YM'><span id='pn3YM'><b id='pn3YM'><form id='pn3YM'><ins id='pn3YM'></ins><ul id='pn3YM'></ul><sub id='pn3YM'></sub></form><legend id='pn3YM'></legend><bdo id='pn3YM'><pre id='pn3YM'><center id='pn3YM'></center></pre></bdo></b><th id='pn3YM'></th></span></q></dt></tr></i><div id='pn3YM'><tfoot id='pn3YM'></tfoot><dl id='pn3YM'><fieldset id='pn3YM'></fieldset></dl></div>

                          <small id='pn3YM'></small><noframes id='pn3YM'>