1. 是否在 iframe 中
1 | // 1.方式一 |
2、w页面中如果想访问iframe中的js方法
3、iframe中的js访问外层w的js方法
4、如果iframe 内部的页面想跨域访问外层window的corodva插件方法
5、顶层url
window.top.location.href
window.parent.location.href
document.referrer
document.loaction
6、常用变量
1、parent常用在iframe和frame中的子页面访问父页面中的对象
2、top :一个页面可能会有很多层,top是指最顶层的框架
3、self :是指当前窗口
7、刷新iframe
1 | document.getElementById('#id').contentWindow.location.reload(true) |
iframe中嵌套html页面中的js调用外层w页面的js方法
其他
拿iframe:window.parent.document.getElementById(‘layui-layer-iframe1’)
拿iframe窗体:window.parent.document.getElementById(‘layui-layer-iframe1’).contentWindow
拿页面doc:window.parent.document.getElementById(‘layui-layer-iframe1’).contentWindow.document
拿js变量或方法:window.parent.document.getElementById(‘layui-layer-iframe1’).contentWindow.变量/方法