如何在没有iFrame的情况下在另一个页面内显示外部网站? [英] How to Show External website inside another page without iFrame?
问题描述
我需要在没有iFrame的情况下在我的应用程序中打开外部网站 我还需要将一些标头值传递给该外部网站.
I need to open External website inside my application without iFrame also I need to pass some header values to that external website.
帮帮我..
推荐答案
iframe的一些替代解决方案是:
Some alternative solutions to an iframe are:
AJAX -您可以使用XMLHttpRequest对象检索数据并将其注入到页面中,例如在div
内部.使用jQuery的示例:
AJAX - You can use the XMLHttpRequest object to retrieve data and inject it to your page, for example inside a div
. Example using jQuery:
$( "#result" ).load( "ajax/test.html" );
HTML5 Web组件-HTML导入是Web组件的一部分,允许将HTML文档捆绑在其他HTML文档中.其中包括HTML,CSS,JavaScript或.html文件可以包含的其他任何内容.示例:
HTML5 Web Components - HTML Imports, part of the Web Components, allows to bundle HTML documents in other HTML documents. That includes HTML, CSS, JavaScript or anything else an .html file can contain. Example:
<link rel="import" href="http://stackoverflow.com">
其他一些想法是:
<object>
标记-定义HTML文档中的嵌入式对象.可以用于HTML文件和多媒体内容,例如音频,视频,小程序,ActiveX,PDF和Flash或其他插件.
<object>
tag - It defines an embedded object within an HTML document. Can be used fot HTML file and multimedia content like audio, video, applets, ActiveX, PDF and Flash or other plugins).
<object data="http://stackoverflow.com" width="400" height="300" type="text/html">
Alternative Content
</object>
<embed>
标记-它为外部应用程序(例如插件)定义了一个容器,也可以对其进行黑客攻击"并用于显示HTML页面.
<embed>
tag - It defines a container for an external application for example a plug-in, in can be also "hacked" and used to display an HTML page.
<embed src="http://stackoverflow.com" width=200 height=200 />
关于传递HEADER,最好的解决方案是使用AJAX方法,这里是一个示例:
Regarding passing HEADER the best solution would be using an AJAX approach, here an example:
$.ajax({
url: "http://stackoverflow.com",
data: { uname: "test" },
type: "GET",
beforeSend: function(xhr){xhr.setRequestHeader('X-TOKEN', 'xxxxx');},
success: function() { alert('Success!' + authHeader); }
});
or in this way,
$.ajax({
url: "http://stackoverflow.com",
data: { uname: "test" },
type: "GET",
headers:{ "X-TOKEN": 'xxxxx'},
success: function() { alert('Success!' + authHeader); }
});
这篇关于如何在没有iFrame的情况下在另一个页面内显示外部网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!