【Web前端】HTML标签iframe:在网页内显示网页

<iframe>标签的作用及用法。

语法

<iframe>可以在网页内显示网页

属性:URL指向网页所在位置

<!-- <iframe src="URL"></iframe> -->
<iframe src="https://www.taobao.com"></iframe>

 

设置宽度和高度 

height 和 width 属性用于规定 iframe 的高度和宽度。

单位默认是像素,也可以使用百分比(如50%)

<iframe src="https://www.hohong.top" width="200" height="200"></iframe>

 

 隐藏网页边框

frameborder属性控制边框是否显示,值为0时隐藏边框,不为0则显示边框

<iframe src="http://www.hohong.top" frameborder="0"></iframe>

 

 代码控制iframe链接到目标网页

如果希望点击一个链接时,跳转网页在iframe显示,可使用target属性,

链接<a>的 target 属性引用 iframe 的 target属性的值(name)

<iframe src="https://www.hohong.top" name="iframeWeb"></iframe>
<a href="http://www.baidu.com" target="iframeWeb">Baidu</a>

 

posted on 2019-04-02 23:44  real-道森  阅读(213)  评论(0)    收藏  举报