公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

中显示的页面的HTML内容?”>

在本文中,我们需要在iframe中显示页面的HTML内容;浏览器窗口划分为单独的页面。我们可以使用 标记及其 srcdoc 属性来完成此任务。

HTML 标签

HTML 中的 标记指定内联框架。该内联框架用于在当前 HTML 文档中嵌入另一个文档。所有浏览器都支持此标签,例如 Google Chrome、Microsoft Edge/Internet Explorer、Firefox、safari 和 Opera 等。

标签的“srcdoc”属性用于指定要在页面中显示的HTML内容。该属性将 HTML_code 作为值并指定要在 中显示的页面的 HTML 内容。

示例 1

在下面的示例中,我们使用带有 标记的“srcdoc”属性来指定要在 HTML 中的 中显示的页面(

元素)的 HTML 内容。

<!DOCTYPE html>
<html>
<head>
   <title>
      How to specify the HTML content of the page to show in the "iframe" in HTML?
   </title>
</head>
<body>
   <h3>How to specify the HTML content of the page to show in the "iframe" in HTML?</h3>
   <p>We can do it by using <b>srcdoc</b> attribute of iframe in HTML.</p>
   <iframe srcdoc="<h2>You can find any tutorial on tutorialspoint</h2>">
      <p>Browser does not support iframes.</p>
   </iframe>
</body>
</html>

登录后复制

正如我们在输出中看到的,文档中的 HTML 内容(

元素)显示在 中。

示例 2

以下是 HTML Iframe 的另一个示例,在此,我们在 iframe 中创建了一个表格。

<!DOCTYPE html>
<html>
<head>
   <title>
      How to specify the HTML content of the page to show in the "iframe" in HTML?
   </title>
</head>
<body>
   <h3>How to specify the HTML content of the page to show in the "iframe" in HTML?</h3>
   <p>We can do it by using <b>srcdoc</b> attribute of iframe in HTML.</p>
   <iframe srcdoc="<table border = 3>
         <caption> Abbreviations </caption>
         <tr>
            <th> HTML </th>
            <th> CSS </th>
         </tr>
         <tr>
            <td> Hypertext markup language</td>
            <td> Cascading style sheet </td>
         </tr>
      </table>">
      <p>Browser does not support iframes.</p>
   </iframe>
</body>
</html>

登录后复制

正如我们在输出中看到的,文档中的 HTML 内容(HTML 表格)显示在 中。

示例 3

默认情况下,所有浏览器都会将 显示为默认值。我们可以使用CSS来改变的样式。

在下面的示例中,

    我们通过使用 CSS 更改 的宽度、高度和边框来更改其样式。

    我们使用带有 标记的“srcdoc”属性来指定要在 HTML 中的 中显示的页面( 元素)的 HTML 内容。

    <!DOCTYPE html>
    <html>
    <head>
       <title>
          How to specify the HTML content of the page to show in the "iframe" in HTML?
       </title>
    </head>
    <body>
       <h3>How to specify the HTML content of the page to show in the "iframe" in HTML?</h3>
       <p>We can do it by using <b>srcdoc</b> attribute of iframe in HTML.</p>
       <iframe srcdoc="<div> Hello Disha</div>" width="50%" height="100" style="border:3px solid green;">
         <p>Browser does not support iframes.</p>
       </iframe>
    </body>
    </html>
    

    登录后复制

    正如我们在输出中看到的,文档中的 HTML 内容( 元素)显示在 中,并且我们还使用 CSS 更改了 的样式。

    以上就是如何在HTML中指定要在<iframe>中显示的页面的HTML内容?的详细内容,更多请关注www.92cms.cn其它相关文章!

分享到:
标签:内容 指定 显示 要在 页面
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定