JS操作iframe】的更多相关文章

转:http://www.css88.com/archives/2343 一.父级窗口操作iframe里的dom JS操作iframe里的dom可是使用contentWindow属性,contentWindow属性是指指定的frame或者iframe所在的window对象,在IE中iframe或者frame的contentWindow属性可以省略,但在Firefox中如果要对iframe对象进行编辑则,必须指定contentWindow属性,contentWindow属性支持所有主流浏览器. 相…
很多人一直都有个想法,要是可以随心所欲的操作iframe就好了.这样静态页面也就有了相当于后台动态页面php,jsp,asp中include,require实现统一多页面布局的能力. 通过Javascript的帮忙我们可以像后台一样动态加载操作iframe对象属性src指向的html页面的内容.这样的操作需要提供两个页面,一个页面是iframe所在页面(页面名称:iPage.html),另一个页面是iframe属性src指向页面(页面名称:srcPage.html). iPage.html,<b…
在做项目时,遇到了操作iframe的相关问题.业务很简单,其实就是在操作iframe内部某个窗体时,调用父窗体的一个函数.于是就写了两个很简单的htm页面用来测试,使用网上流行的方法在谷歌浏览器中始终报错,不能通过. 父页面parent.html的代码如下 <html xmlns="http://www.w3.org/1999/xhtml"> <head><title> </title> <script src="jque…
1. 获得iframe的window对象 存在跨域访问限制. chrome:iframeElement. contentWindow firefox: iframeElement.contentWindow ie6:iframeElement.contentWindow 文章Iframes, onload, and document.domain中说“he iframe element object has a property called contentDocument that conta…
一 在父页面操作子页面   IE下操作IFrame内容的代码: document.frames["MyIFrame"].document.getElementById("s").style.color="blue"; 但是这在Firefox下无效.所以,想到在Firefox下用FireBug来调试.经过调试发现在Firefox下可用以下代码来实现:   document.getElementById("MyIFrame").c…
1.  demo1.html页面中有个iframe元素,iframe元素的src是iframe1.html,怎么在demo1.html页面中操作iframe1.html页面 答曰:demo1.html中,js先找到iframe元素(比如命名为:oIframe),那么oIframe.contentWindow就是iframe1.html这个页面的window,剩下了就是DOM操作的事情了. 举例:要求:demo1.html页面中有个按钮,点击按钮,iframe1页面某些文字改变颜色 <!DOCTY…
1.获取iframe的window对象 存在跨域访问限制. iframeElement.contentWindow 兼容 2.获取iframe的document对象 存在跨域访问限制. chrome: iframeElement.contentDocument firefox: iframeElement.contentDocument ie:iframeElement.contentWindow.document(ie没有iframeElement.contentDocument属性) var…
如果当前窗口不是最上层窗口(比如是在Iframe中),那么就把自己变为最上层窗口.  <script language="javascript" type="text/javascript">        if (window.top != null && window.top.location != window.location) {            window.top.location = window.location;…
document.getElementById("ifarme-63").contentWindow.document.getElementById("qksv").value = '1'; document.getElementById("ifarme-63").contentWindow.document.getElementById("hfDateStart").value = '20150101'; document.…
这里简单说明两个方法,都是未跨域情况下在index.html内操作b.html内的 DOM. 如:index.html内引入iframe,在index内如何用JS操作iframe内的DOM元素? 先贴下index.html和iframe引入的a.html内容. index-> <div class="d1"> <iframe src="a.html" frameborder="0" name="one"…