关于JS子父页面互调心得@TOC
js父子页面互调
首先确定是子调父还是父调子
子调父
btnSearch为按钮的Id
window.parent.document.getElementById(‘btnSearch’).click();
父调子
childFunctionName()这个是你的方法名
$("#oiframes")[0].contentWindow.childFunctionName(); 或 document.getElementById("#oiframes").contentWindow.childFunctionName();
也可这样去找你的元素Id
$("#oiframes")[0].contentWindow.document.getElementById(‘btnSave’);或 document.getElementById("#oiframes").document.getElementById(‘btnSave’);
找不到子页面iframe的Id怎么办
这样就可以找到
document.getElementsByTagName(‘iframe’).item(i).contentWindow.document.getElementById(‘btnSave’);