parent.document.getElementById('mainFrame').contentWindow.document.getElementById('tt');
前面的去哪里能够找得到(在那一层?)
parent 主要是iframe 内嵌的时候子模块调用父模块用到的。
就是指的contentWindow当前id为tt的元素嘛
1、parent.document.getElementById('mainFrame')找到父窗口id="mainFrame"的元素;
2、contentWindow找到id="mainFrame"的子窗口的 window 对象;
3、document.getElementById('tt')获取子窗口中id="tt"的元素。
整句话就是要获取同级兄弟窗口的id="tt"的元素。
注意:contentWindow 兼容各个浏览器,可取得子窗口的 window 对象。