zoukankan      html  css  js  c++  java
  • HTML5 iFrame

      

    定义和用法

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

    提示和注释:

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

    属性

    new : HTML5 中的新属性。

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

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

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

    frameborder
    • 1
    • 0
    规定是否显示框架周围的边框。
    height
    • pixels
    • %
    规定 iframe 的高度。
    longdesc URL 规定一个页面,该页面包含了有关 iframe 的较长描述。
    marginheight pixels 定义 iframe 的顶部和底部的边距。
    marginwidth pixels 定义 iframe 的左侧和右侧的边距。
    name frame_name 规定 iframe 的名称。
    sandbox
    • ""
    • allow-forms
    • allow-same-origin
    • allow-scripts
    • allow-top-navigation
    启用一系列对 <iframe> 中内容的额外限制。
    scrolling
    • yes
    • no
    • auto
    规定是否在 iframe 中显示滚动条。
    seamless seamless 规定 <iframe> 看上去像是包含文档的一部分。
    src URL 规定在 iframe 中显示的文档的 URL。
    srcdoc HTML_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').....
  • 相关阅读:
    更博不能忘——webpack学习笔记
    面试中遇到过的闭包~
    github踩坑之git命令收集与整理(windows)
    应该写个博客
    重学C语言(一):熟悉汇编语言
    关于Swift的闭包(closure)以及其在可选(Optional)类型中的应用
    解决Xcode 7出现cdtool cannot compile的问题(2015年8月12日更新)
    更改LaTeX的数学模式中使用的字体
    在Mac下安装使用支持中文的LaTeX(二)
    在Mac下安装使用支持中文的LaTeX(一)
  • 原文地址:https://www.cnblogs.com/echo777/p/11068306.html
Copyright © 2011-2022 走看看