由于跨域,不能用ajax. 父页面控制iframe中的表单提交,根据iframe中页面的返回值,在父页面做出相应回应。但是在表单提交后取值的时候,总是firebug提示"Permission denied to get property HTMLDocument.body". 怀疑是权限问题,但不知道错在哪里。高分请教!!
相应代码如下:var doc = document.getElementById('interface_data').contentWindow.document; //'interface_data'是iframe的id
doc.getElementById('topicid').value = v;
doc.getElementById('form_addTo').action = action; //'form_addTo'是iframe页面中的form 的id
doc.getElementById('form_addTo').submit();
var oFrm = document.getElementById("interface_data");
oFrm.onload = oFrm.onreadystatechange = function() {
if (this.readyState && this.readyState != 'complete') return;
else{
if (document.all){//IE
var sub_con = document.frames["interface_data"].document;
}else{//Firefox
var sub_con = document.getElementById("interface_data").contentDocument;
}
sub_con = sub_con.body.innerHTML; //取得返回值
alert(sub_con);
}
相应代码如下:var doc = document.getElementById('interface_data').contentWindow.document; //'interface_data'是iframe的id
doc.getElementById('topicid').value = v;
doc.getElementById('form_addTo').action = action; //'form_addTo'是iframe页面中的form 的id
doc.getElementById('form_addTo').submit();
var oFrm = document.getElementById("interface_data");
oFrm.onload = oFrm.onreadystatechange = function() {
if (this.readyState && this.readyState != 'complete') return;
else{
if (document.all){//IE
var sub_con = document.frames["interface_data"].document;
}else{//Firefox
var sub_con = document.getElementById("interface_data").contentDocument;
}
sub_con = sub_con.body.innerHTML; //取得返回值
alert(sub_con);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货