在iframe中获取本iframe DOM引用】的更多相关文章

window.frameElement 获取本iframe DOM window.frameElement.contentDocument.getElementById('id') 获取这个iframe中的元素 晚上写 3-9 Blocked a frame with origin "null" from accessing a frame with origin "null" chrome出现这问题的话就是A.B 2个页面不同域, A包含了B页面,B引用A页面某些…
在web开发中,经常会用到iframe,难免会碰到需要在父窗口中使用iframe中的元素.或者在iframe框架中使用父窗口的元素 js 在父窗口中获取iframe中的元素  1. 格式:window.frames["iframe的name值"].document.getElementById("iframe中控件的ID").click(); 实例:window.frames["ifm"].document.getElementById(&quo…
  第一种情况:iframe中不存在name和id的方法:(通过contentWindow获取) var iframe = document.getElementsByTagName('iframe')[0];var ifr_document = iframe.contentWindow.document;//iframe中的文档内容 或者: var _iframe = document.getElementByIdx_x('iframeId').contentWindow; var _div…
1.jsx语法 var names = ['Alice', 'Emily', 'Kate']; <!-- HTML 语言直接写在 JavaScript 语言之中,不加任何引号,这就是 JSX 的语法,它允许 HTML 与 JavaScript 的混写 --> ReactDOM.render( <div> { names.map(function (name) { return <div>Hello, {name}!</div> }) } </div&g…
a.html <!DOCTYPE html> <html> <head> <title></title> </head> <body> <div id="a">hello world!!!</div> <div id="b"> <iframe id="frm" name="frm" src="…
parent.document.getElementById("dom ID"); $($(parent.document.getElementById("video-iframe")).parent().parent()).children('div.vid-tags').text(desc); parent,top还能调用父级窗口的的js方法,比如,getIFrameDOM(iID)是父级窗口的一个方法,那么iframe里可以使用parent.getIFrame…
window.frameElement   返回嵌入当前window对象的元素(比如 <iframe> 或者 <object>),如果当前window对象已经是顶层窗口,则返回null.   var frameId = window.frameElement && window.frameElement.id || '';      …
$(top.parent.iframeId).contents().find("#selector") //iframeId为iframe的id名称…
原文链接:https://jingyan.baidu.com/article/f96699bbfe9c9d894f3c1b4b.html 两种解决方案: 1:官方解决方案: 受到 HTML 本身的一些限制,变通的方案是使用特殊的 is 特性 应当注意,如果使用来自以下来源之一的字符串模板,则没有这些限制: eg1:用<script type="text/x-template"> 将 <comp></comp> 改为 <script type=&…
function getRootWin(){       var win = window;       while (win != win.parent){            win = win.parent;        }       return win;   }…
iframe与父页面之间相互获取元素的方法: 1.从父页面中获取iframe页面中的元素: 用法: $(window.frames["iframe_include_adverse"].document).find() 如:$(window.frames["iframe_include_adverse"].document).find("input:not(:hidden[name*='_'])"),从父页面获取iframe页面中 除去隐藏域(hi…
转载: Js/Jquery获取iframe中的元素 - - ITeye技术网站http://java-my-life.iteye.com/blog/1275205 在web开发中,经常会用到iframe,难免会碰到需要在父窗口中使用iframe中的元素.或者在iframe框架中使用父窗口的元素. js 在父窗口中获取iframe中的元素 1. 格式:window.frames["iframe的name值"].document.getElementById("iframe中控件…
今天要修改编辑器插件中的元素遇到的问题 jquery 在父窗口中获取iframe中的元素 1.Js代码 格式:$("#iframe的ID").contents().find("#iframe中的控件ID").click();//jquery 方法1 实例:$("#ifm").contents().find("#btnOk").click();//jquery 方法1 2.Js代码 格式:$("#iframe中的控件I…
父窗口中获取iframe中的元素 var ifr = document.getElementById('suggustion').contentWindow.document.body; 在iframe中获取父窗口的元素 格式:window.parent.document.getElementByIdx_x("父窗口的元素ID").click(); 实例:window.parent.document.getElementByIdx_x("btnOk").click(…
今天研究了一下iframe中元素的获取,发现有些地方还是有点坑的. 首先:如果使用纯前端手段,是没有办法获取非同源的iframe中的元素的,后面会提到后端手段 一.同源环境 1.首先在父页面获取iframe中的window,然后获取元素,根据window,不仅可以获取元素,还能调用里面的方法,前提是绑定在window上面 ].contentWindow; ifW.document.getElementsByClassName('wrap') 2.在iframe中获取父页面的window wind…
js 在父窗口中获取iframe中的元素 1. 格式:window.frames["iframe的name值"].document.getElementById("iframe中控件的ID").click(); 实例:window.frames["ifm"].document.getElementById("btnOk").click(); 2. 格式: var obj=document.getElementById(&quo…
在iframe中获取父窗口的元素 $(‘#父窗口中的元素ID’, parent.document).click(); 在父窗口中获取iframe中的元素 $(“#iframe的ID”).contents().find(“#iframe中的控件ID”).click();…
jquery方法 在父窗口中获取iframe中的元素 //方法1 $("#iframe的ID").contents().find("iframe中的元素"); //实例: $("#ifr").contents().find("#someid"); //方法2 $("#iframe中的控件ID",document.frames("frame的name").document); //实例 $…
这一个月又没更新博客,唉,懒癌又犯了,今天解决了一个问题,关于两个iframe互相调用jquery函数方法 a.html中有两个iframe,如下: <iframe width="100%" height="100%" name="left" scrolling="auto" frameborder="0" src="b.html" id="left">&…
<iframe src="html的路径(至于MVC中cshtml直接路径好像是不行的,得使用action进行请求出来的路径)" id="iframechild" style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%;"></iframe> $("#iframechild").contents().find(&…
先来看看position: fixed:的定义:生成绝对定位的元素,相对于浏览器窗口进行定位: 但是在iframe中使用fixed定位,实际上是相对于iframe窗口进行定位,原因在于iframe类似于创建了一个浏览器窗口,在使用一些获取鼠标位置以及元素位置等方法的时候把iframe当作浏览器窗口来处理就行. 以下是一些在iframe中使用fixed需要考虑的常用js事件对象属性与方法: 获取鼠标的位置: e.clientY // 获取鼠标在浏览器视窗的Y坐标,在iframe中相对于iframe…
摘自:http://blog.csdn.net/kongjiea/article/details/38870399 1.在父页面 获取iframe子页面的元素 (在同域的情况下 且在http://下测试,且最好在iframe onload加载完毕后 dosomething...) js写法 a.同过contentWindow获取 也有用contentDocument 获取的 但是contentWindow 兼容各个浏览器,可取得子窗口的 window 对象.contentDocument Fir…
在不使用三大框架的情况下,iframe的使用可以做到在页面中直接引入别的页面作为当前页面的一部分,但是在iframe的使用过程中存在一些相互之间的操作 例如在iframe中获取主页面的元素,使用主页面的js中定义的方法 第一.在iframe中查找父页面元素的方法: $('#id', window.parent.document) 第二.在父页面中获取iframe中的元素方法: $(this).contents().find("#suggestBox")   第三.在iframe中调用父…
使用jquery操作iframe中的元素<iframe src="/test/demo.htm" width="99%" height="300" id="frameTHY"></iframe><pre><script>window.onload = function() { $( "#frameTHY" ).contents().find( "a&…
在前台登录页面中加入JS代码,判断登录页面是否在iframe中,在iframe中就跳转出去 例: //判断是否在iframe中,在里面就跳出去 if (top.location.href != location.href) { top.location.href = '${base}/login.jhtml'; } 这种情况下会出现iframe中先嵌套登录页面然后才会跳转出去,也是可以解决的,把这段代码放在最上面,就是引入css后就引入这段代码,js 的暂停加载,就可以解决这个问题…
太扯了,一个多小时都没搞定,获取不到iframe中的dom元素. <div id="one"> this is one </div> <div> <iframe src="./demo.html" id="test"> </iframe> </div> <script type="text/javascript"> console.log(wi…
父窗口中操作iframe:$(window.frames["iframeChild"].document)    //假如iframe的id为iframeChild 在子窗口中操作父窗口:$(window.parent.document) 接下来就可以继续获取iframe内的dom了. 获取iframe内的dom对象有两种方法 1 $(window.frames["iframeChild"].document).find("#child") 2…
父窗口中操作iframe: $(window.frames["iframeChild"].document) //假如iframe的id为iframeChild 在子窗口中操作父窗口: $(window.parent.document) 接下来就可以继续获取iframe内的dom了. 获取iframe内的dom对象有两种方法 1 $(window.frames["iframeChild"].document).find("#child") 2 $…
父窗口中操作iframe:window.frames["iframeChild"].document //假如iframe的id为iframeChild 在子窗口中操作父窗口:window.parent.document 那么,用如果想用jquery的方法,我们怎么用jquery来获取iframe呢?下面是一下收集来的方法. 获取页面的对象其实就是dom方法外面加上jquery的选择符: 父窗口中操作iframe:$(window.frames["iframeChild&qu…
query取得iframe中元素的几种方法 在iframe子页面获取父页面元素代码如下: $('#objId', parent.document);// 搞定... 在父页面 获取iframe子页面的元素代码如下: $("#objid",document.frames('iframename').document) 显示iframe中body元素的内容. $(document.getElementById('iframeId').contentWindow.document.body)…