日期:2014-05-16  浏览次数:20426 次

奇怪了,FF通过,IE没通过
content   =   content.replace(/{!title}/,   title.value);
content   =   content.replace(/{!time}/,   time);
content   =   content.replace(/{!email}/,   email.value);
content   =   content.replace(/{!author}/,   author.value);
content   =   content.replace(/{!avatar}/,   avatar.value);
content   =   content.replace(/{!message}/,   message.value);
maincontent   =   document.getElementById( "maincontent ");
ele   =   document.createElement( "div ");
ele.className   =   "msg ";
ele.innerHTML   =   content;

这条代码在IE下报错。
把maincontent   =   document.getElementById( "maincontent ");删掉就没错误。。这个语句哪里错了??

------解决方案--------------------
<script type= "text/javascript ">
window.onload = function () {
content = content.replace(/{!title}/, title.value);
content = content.replace(/{!time}/, time);
content = content.replace(/{!email}/, email.value);
content = content.replace(/{!author}/, author.value);
content = content.replace(/{!avatar}/, avatar.value);
content = content.replace(/{!message}/, message.value);
maincontent = document.getElementById( "maincontent ");
ele = document.createElement( "div ");
ele.className = "msg ";
ele.innerHTML = content;
/*
...
放到window.onload 里呢?*/
}
</script>