如何用JS操作iFrame里的Dom
来源:互联网 发布:知春家园医院 编辑:程序博客网 时间:2024/04/29 02:58
如题,父页面的JS如何拿到iframe里的dom,并且进行操作? 原生JS,不用JQ之类的 页面代码:
<body> <iframe id="container" name="container" src="frames/index.html"></iframe>
</body>
在chrome的console里: document.getElementById("container")Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.
Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match. Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.
<iframe id="container" name="container" src="frames/index.html">...</iframe>
document.getElementById("container").contentWindow.documentBlocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.
undefined
window.frames["container"].documentBlocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match.
undefined
虽然是相对路径,还是出现跨域的错误。
最后找到原因了,文件之间的操作是按照跨域处理的,把文件放在web容器里,127.0.0.1 去访问就好了
原文:http://segmentfault.com/q/1010000000199925
- 如何用JS操作iFrame里的Dom
- JS操作iframe里的dom
- JS操作iframe里的dom
- JS操作iframe里的dom,js iframe
- 用JS访问操作iframe里的dom
- 用JS访问操作iframe框架里的dom
- 用JS访问操作iframe里的dom
- 用 JS访问操作iframe里的dom
- JS操作iframe里的DOM || contentWindow,contentDocument
- 如何用JS求DOM树的最大深度?
- 用javascript访问操作iframe里的dom
- 用javascript访问操作iframe里的dom
- 用javascript访问操作iframe里的dom
- js操作iframe中的dom
- 关于 JS操作 iframe DOM
- JS操作父窗口里的DOM
- 如何用js判断两个文本框里的日期是否在同一个月里???
- 调用iframe里的JS
- 【Linux】将Vim改造成IDE
- 分布式系统应对雪崩及如何防范数据被非法篡改
- 浅谈Servelt
- ubuntu安装android系统编译环境
- Java程序性能优化-概述
- 如何用JS操作iFrame里的Dom
- 线程池多线程比较实例
- gc overhead limit exceeded eclipse解决方案
- 微软不也是从Altair Basic这丑小鸭长成白天鹅吗?- 创业教父Paul Graham如何看待创意
- 转:多表链接 Left join
- 括号配对问题
- php连接Access数据库的三种方法
- Qt QGroupBox切换调用问题
- QT全局宏变量的实现