IE7下面操作iframe的问题
在项目中碰到如下一个问题:通过Ajax返回一个字符串,其中包含有一个链接信息,是用来设置页面上iframe的src的、、、
function showResponse(responseText, statusText) {
var res = jQuery.trim(responseText).split("||");
if(res.indexOf(". ")>0){
res = res.replace(". ",".\r\n");
}
$("#msg").val(res);
if(null!=res&&""!=res){
//$("#preShowValueIFrame").attr("src",res);
//document.getElementById("preShowValueIFrame").src=res;
document.getElementById("preShowValueIFrame").setAttribute("src",res);
}
}
文中红色加粗部分,对于被注释掉的两种设置方法,在IE7下面会报错“invalid argument”。
最后查到通过setAttribute方法来进行设值,ok,搞定了、、、O(∩_∩)O~
页:
[1]