如何在没有 iFrame 的情况下在另一个页面内显示外部网站? [英] How to Show External website inside another page without iFrame?

查看:19
本文介绍了如何在没有 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">

其他一些想法是:

标签 - 它定义了 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆