HTML5 iFrame

博客介绍了iframe元素,它可创建包含另一文档的内联框架。还给出提示,可在标签间放置文本以应对不理解iframe的浏览器。此外,展示了在父HTML里操作iFrame的示例,以及如何改变src中HTML的属性。

  

定义和用法

iframe 元素会创建包含另外一个文档的内联框架(即行内框架)。

提示和注释:

提示:您可以把需要的文本放置在 <iframe> 和 </iframe> 之间,这样就可以应对无法理解 iframe 的浏览器。

属性

new : HTML5 中的新属性。

属性描述
align
  • left
  • right
  • top
  • middle
  • bottom

不赞成使用。请使用样式代替。

规定如何根据周围的元素来对齐此框架。

frameborder
  • 1
  • 0
规定是否显示框架周围的边框。
height
  • pixels
  • %
规定 iframe 的高度。
longdescURL规定一个页面,该页面包含了有关 iframe 的较长描述。
marginheightpixels定义 iframe 的顶部和底部的边距。
marginwidthpixels定义 iframe 的左侧和右侧的边距。
nameframe_name规定 iframe 的名称。
sandbox
  • ""
  • allow-forms
  • allow-same-origin
  • allow-scripts
  • allow-top-navigation
启用一系列对 <iframe> 中内容的额外限制。
scrolling
  • yes
  • no
  • auto
规定是否在 iframe 中显示滚动条。
seamlessseamless规定 <iframe> 看上去像是包含文档的一部分。
srcURL规定在 iframe 中显示的文档的 URL。
srcdocHTML_code规定在 <iframe> 中显示的页面的 HTML 内容。
width
  • pixels
  • %
定义 iframe 的宽度。

 

关于怎样在父HTML里面操作iFrame。

比如:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>

</script>
</head>
<body>

<input type='text' class='test'></input>
<iframe id="iframe" name="button-skin" src="/pages/console/system_report.html" ></iframe>
</body>
</html>

system_report.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>

</script>
</head>
<body>
<button class='button'>测试</button>
</body>
</html>

其中src里面又是一个HTML,那么 改变html的 属性呢。

$(window.frames['button-skin'].document).find('body'),这样是得到整个嵌套的html的 body。
$(window.frames['button-skin'].document).find('.button')这样可以操作button
但是一定要注意的是iframe里的html也有可能会加载延迟,这样的话就会得到
window.frames['button-skin']=undefined的错误。
怎样通过iframe里的属性改变父html的属性
$(window.parent.document).find(....)各种各样的操作。
$(window.parent.document).find('.class').....

转载于:https://www.cnblogs.com/echo777/p/11068306.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值