jQuery IFrame 替代品
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3450228/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
IFrame alternatives
提问by tonyf
Is there anything else I could use instead of an iframe on my web page by where I still need to pass a url or is iframe it?
在我的网页上还有什么我可以使用而不是 iframe 的,我仍然需要传递一个 url 或者是 iframe 吗?
Thanks.
谢谢。
回答by Kris van der Mast
Since you put jQuery as a tag I suggest you either look at http://api.jquery.com/load/.
由于您将 jQuery 作为标签,我建议您查看http://api.jquery.com/load/。
回答by Ken Struys
You can use an ajax request to fetch the content and then just inject it into the page but that won't work cross domain, so if you're trying to host external content iframe is the way to go.
您可以使用 ajax 请求来获取内容,然后将其注入页面,但这不会跨域工作,因此如果您尝试托管外部内容 iframe 是可行的方法。
回答by Moe Salih
you can create a div and fill this div in multiple ways, either do an ajax request or if you're using any server scripting language you can just do an include inside the div.
您可以创建一个 div 并以多种方式填充这个 div,或者执行 ajax 请求,或者如果您使用任何服务器脚本语言,您可以在 div 中执行包含。
using iframes is still the cleanest options for most uses.
对于大多数用途,使用 iframe 仍然是最干净的选择。
回答by kern
There is no other option for crossdomain embedding unless you use the HTML <frameset>
element, which I strongly do not recommend. You can, however, hide the iframe using CSS.
除非您使用 HTML<frameset>
元素,否则没有其他选项可用于跨域嵌入,我强烈不推荐这样做。但是,您可以使用 CSS 隐藏 iframe。
Crossdomain communicationcan be done in a variety of ways as well.
跨域通信也可以通过多种方式完成。
回答by Swanidhi Singh
I don't think there is anything else you can use, as an alternative to an iframe. Considering the fact, that the URL will change upon clicking on any link inside the iframe, will change the content. This, otherwise can be a tedious and challenging. The moment you click a link, you are bound to be redirected to it. Hence, no.
我不认为您可以使用其他任何东西来替代 iframe。考虑到这样一个事实,即点击 iframe 内的任何链接时 URL 都会改变,这将改变内容。否则,这可能是乏味和具有挑战性的。单击链接的那一刻,您一定会被重定向到它。因此,没有。
回答by James Wiseman
You'll need to tell us a bit more about what you're trying to do so we can help you out a bit more.
您需要更多地告诉我们您正在尝试做什么,以便我们为您提供更多帮助。
It sounds like an HTTP Request/AJAX might fit the bill, but its hard to say at the moment.
听起来 HTTP 请求/AJAX 可能符合要求,但目前还很难说。