//通过这样即可获取iframe中的元素
document.getElementById("myFrame").contentWindow.document.getElementById('ss').innerHTML;
// 等价于
window.frames[0] // is the same thing as
document.getElementsByTagName("iframe")[ 0 ].contentWindow
var frames = window.frames; // or // var frames = window.parent.frames;
for (var i = 0; i < frames.length; i++) {
// do something with each subframe as frames[i]
frames[i].document.body.style.background = "red";
}
window.onload = (function () {
var iObj = document.getElementById('iId').contentWindow;
alert(iObj.document.getElementsByTagName('h1')[0].firstChild.data);
});
//此方法经过ie6,ie7,firefox2.0,firefox3.0测试都通过
// firefox下访问操作iframe里内容
var iObj = document.getElementById('iId').contentDocument;
alert(iObj.getElementsByTagName('h1')[0].innerHTML='我想变成她一天的一部分');
alert(iObj.getElementsByTagName('p')[0].firstChild.data);
//通过designMode(设置文档为可编辑设计模式)和contentEditable(设置内容为可编辑),你可以重写iframe里的内容。代码:
var iObj = document.getElementById('iId').contentWindow;
iObj.document.designMode = 'On';
iObj.document.contentEditable = true;
iObj.document.open();
iObj.document.writeln('<html><head>');
iObj.document.writeln('<style>body {background:#000;font-size:9pt;margin: 2px; padding: 0px;}</style>');
iObj.document.writeln('</head><body></body></html>');
iObj.document.close();
// JS获取iframe元素及跨域访问操作
http://www.ribenyu.cn/space-1-do-blog-id-3443.html
分享到:
相关推荐
通过HTTPClient界面在JSP中嵌入iframe子界面跨域时,无法获取跨域界面的属性值的问题
iframe 跨域访问session问题解决方法
知道什么是跨域以及解决跨域的方法,但是具体实际从来没有操作过,直到最近在公司项目中,遇到了一个需要使iframe跨域进行POST提交的实际案例,我才明白具体如何使用iframe进行跨域操作。 说到跨域,就不得不提起...
框架完美解决了iframe之间的跨域通讯。底层技术采用window.name转换代理实现
vue 2.0跨域问题?.docx
NULL 博文链接:https://hqlly.iteye.com/blog/1662337
iframe跨域问题:Uncaught DOMException Blocked a frame with origin解决方法
这是关于iframe使用过程中出现的问题整理的解决方法,关于使用iframe不用单独写接口打通数据,直接把数据通过ifarme嵌套方法传递过去,使用简单方便。
iframe 跨域 自动适应高度;iframe 跨域 自动适应高度;
js跨域对象类,纯js代码,未引入任何js库。
1、为ScriptManager添加脚本引用,不从ScriptResource.axd中加载MicrosoftAjax.js脚本,而是直接加载 <asp:ScriptReference Name="MicrosoftAjax.js" ScriptMode="auto" Path="~/ScriptLibrary/System.Web....
该文档介绍了vue和普通web页面中iframe实现跨域的解决方案,解决了主页面中无法调用iframe方法的问题
iframe 与主框架相互访问例子,包含同域访问,跨域访问例子。
iframe跨域访问示例
通过JS技术解决引入iframe页面引起的跨域问题,postmessage解决iframe页面跨域问题
js跨域解决方案
在web开发中,跨域问题是经常遇到的,但是由于浏览器同源策略的限制,不同域之间属性和操作是无法直接交互的。本次讨论iframe和父页面的消息通信。
iframe跨域,里面包含四个文件,具体使用方式参考代码,
实现内嵌的iframe跨域调用父页面js方法
iframe 跨域 自适应高度 模板 iframe 跨域 自适应高度 模板 iframe 跨域 自适应高度 模板