iframe父子窗口的相互调用

    技术2022-05-19  22

    页面内的frame

     

    <iframe name="countryFrame" src="country.jsp" mce_src="country.jsp" height="300" width="200" frameborder="0" > </iframe>

    country.jsp

    <input type="checkbox" name="checkbox" class="checkbox" id="CN-11" value="北京" οnclick="objClick(this)"/> 北京 </li> <li> <input type="checkbox" name="checkbox" class="checkbox" id="CN-31" value="上海" οnclick="objClick(this)"/> 上海 </li> <li> <input type="checkbox" name="checkbox" class="checkbox" id="CN-33" value="浙江" οnclick="objClick(this)"/> 浙江 </li> <li> <input type="checkbox" name="checkbox" class="checkbox" id="CN-12" value="天津" οnclick="objClick(this)"/> 天津 </li>

     

    当前页面调用iframe指向的页面

    //获得iframe内对象 var checkbox=window.frames['countryFrame'].document.getElementsByName("checkbox"); var geoCheckbox=0+","; for(var i=0;i<checkbox.length;i++){ //alert(checkbox[i].checked); if(checkbox[i].checked==true){ geoCheckbox+=window.frames['countryFrame'].document.getElementsByName("checkbox")[i].value+","; } }

     

    iframe页面调用其上一级页面

     

    window.parent.codeAddressWithParm(address);

    调用上级的window.parent.codeAddressWithParm(address)函数

     


    最新回复(0)