首页 > 解决方案 > 在像 iframe 这样的 div 中加载整个 html

问题描述

我需要在 div 中显示一个 html 页面,例如具有滚动功能的 iframe。

<div [innerHtml]="safeHtmlContent | safehtml" style='overflow:auto;
white-space: nowrap; position: static; 
width:500px;height:550px;'>here is some text</div>

它可以加载 html 内容,但问题是内容未对齐,并且 html 页面的粘性标题替换了我的标题。

那么如何才能仅在 div 中加载 html 内容。

我的示例 html 内容:

<!DOCTYPE html>
    <html itemscope itemtype="http://schema.org/QAPage" class="html__responsive">
    <head>
        <title>angular - Angular4 Load external html page in a div - Stack Overflow</title>
        <link rel="shortcut icon" href="https://cdn.sstatic.net/Sites/stackoverflow/img/favicon.ico?v=4f32ecc8f43d">
        <link rel="apple-touch-icon image_src" href="https://cdn.sstatic.net/Sites/stackoverflow/img/apple-touch-icon.png?v=c78bd457575a">
        <link rel="search" type="application/opensearchdescription+xml" title="Stack Overflow" href="/opensearch.xml">
        <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, minimum-scale=1.0"> ......

提前致谢。

标签: javascripthtmlcssangularbootstrap-4

解决方案


推荐阅读