如何将外部 html 文件嵌入当前 html 文件但没有 iframe 标签

how to embed external html file into current html file but without iframe tag

我需要在没有 iFrame 的情况下打开当前 html 文件中的外部网站

帮帮我..

您可以尝试这样的对象标签:

<object type="text/html" data="http://validator.w3.org/" width="800px" height="600px" />

iframe 的一些替代解决方案是:

AJAX - 您可以使用 XMLHttpRequest 对象检索数据并将其注入您的页面,例如在 div 中。使用 jQuery 的示例:

 $( "#result" ).load( "ajax/test.html" );

HTML5 Web 组件 - HTML 导入,Web 组件的一部分,允许在其他 [=39] 中捆绑 HTML 文档=] 文件。这包括 HTML、CSS、JavaScript 或 .html 文件可以包含的任何其他内容。示例:

   <link rel="import" href="http://whosebug.com">

其他一些想法是:

<object> 标签 - 它定义了 HTML 文档中的嵌入对象。可用于 HTML 文件和多媒体内容,如音频、视频、小程序、ActiveX、PDF 和 Flash 或其他插件)。

   <object data="http://whosebug.com" width="400" height="300" type="text/html">
        Alternative Content
    </object>

<embed> 标签 - 它为外部应用程序定义容器,例如插件,也可以是 "hacked" 并用于显示 HTML 页面。

<embed src="http://whosebug.com" width=200 height=200 />

关于传递 HEADER,最好的解决方案是使用 AJAX 方法,这里有一个例子:

$.ajax({
    url: "http://whosebug.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://whosebug.com",
    data: { uname: "test" },
    type: "GET",
    headers:{ "X-TOKEN": 'xxxxx'},
    success: function() { alert('Success!' + authHeader); }
});