在iframe中获取父页面的元素】的更多相关文章

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="…
在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…
在不使用三大框架的情况下,iframe的使用可以做到在页面中直接引入别的页面作为当前页面的一部分,但是在iframe的使用过程中存在一些相互之间的操作 例如在iframe中获取主页面的元素,使用主页面的js中定义的方法 第一.在iframe中查找父页面元素的方法: $('#id', window.parent.document) 第二.在父页面中获取iframe中的元素方法: $(this).contents().find("#suggestBox")   第三.在iframe中调用父…
javascript获取iframe框架中,加载的页面document对象 因为浏览器安全限制,对跨域访问的页面,其document对象无法读取.设置属性 function getDocument(iframe)         {             var Doc;             try{                 Doc = iframe.contentWindow.document;// For IE5.5 and IE6             }         …
父页面的代码 <div id="div5" style="position:relative;height:500px;">                       <iframe scrolling="auto" frameborder="0"  id="content" name="content" src ="./cpcia_gonggao.jsp&…
在iframe子页面获取父页面元素 代码如下: $.('#objld', parent.document); 在父页面获取iframe子页面的元素 代码如下: $("#objid", document.iframes('iframe').document) 或 代码如下: $(document.getElementById('iframeId').contentWindow.document.body).html() $(document.getElementById('iframeI…
在iframe中获取父窗口的元素 $(‘#父窗口中的元素ID’, parent.document).click(); 在父窗口中获取iframe中的元素 $(“#iframe的ID”).contents().find(“#iframe中的控件ID”).click();…
父页面中: <input type="hidden" id="areaID" value="test1"> <iframe align="center" style="width: 100%; height: 100%;" frameborder="0" scrolling="no" src="Html//test.jsp">…
项目中发现要在iframe的弹框中获取父页面中的元素,我们可以按照如下代码操作:$(window.parent.document).find('selector').attr('XXX') 如果我们需要获取父页面的window对象,我们可以使用如下代码操作:window.parent.location.hash 如果我们获取的是最顶层的页面,那么我么可以通过window.top来实现:…