document.body.appendChild(ⅰ) [英] document.body.appendChild(i)
本文介绍了document.body.appendChild(ⅰ)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我只在IE7中收到错误,因为document.body为null,我调试Microsoft脚本编辑器在后面的行中出错:
ie
I am getting error only in IE7 as document.body is null, wehn i debug Microsoft script editor getting error in follwing line: ie
document.body.appendChild(i)
代码:
document.body.appendChild(i) code:
function nm_eraseCookie(name){
nm_createCookie(name,"",-1)
}
var i=document.createElement('IMG');
i.src='//e.netmng.com/pixel/?aid=403';
i.width=1;
i.height=1;
document.body.appendChild(i);
nm_createCookie('nm_belgacom_bt',
escape('tv1=bun_intvtel;tv2=;tv3=;phone1=hbs_discoveryline;phone2=hbs_classical_line;phone3=;inet1=bun_nettvmob;inet2=hbs_adsl_res_plus;inet3=hbs_adsl_res_go;nm_banner=;nm_popin=hbs_discoveryline;'),183);
你能否告诉我解决这个问题需要做些什么。
Can you infomr me what i need to do to solve this issue.
推荐答案
这是有效的。只需修改为空检查:
It is working. Just modify to null check:
if(document.body!= null){
document.body.appendChild(element) ;
}
if(document.body != null){ document.body.appendChild(element); }
Pointy的建议很好;它可能有用,但我没试过。
Pointy's suggestion is good; it may work, but I didn't try.
这篇关于document.body.appendChild(ⅰ)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文