<script language=javascript>
function preview(oper) {
bdhtml=window.document.body.innerHTML;
sprnstr="<!--startprint-->";
eprnstr="<!--endprint-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+18);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
if(oper<10)
{openwindow=window.open('preview.htm',"打印预览","toolbar=no,menubar=no,resizable=yes,status=no,scrollbar=yes");
openwindow.document.body.style.textAlign="center";
window.document.body.innerHTML=prnhtml;
window.print(); }
}
</script>运行的时候总是,在openwindow.document.body.style.textAlign="center";报错,说body不存在,我调试了一下,openwindow.document添加监视还有值,openwindow.document.body就没有了,请问这是为什么,该怎么改??
function preview(oper) {
bdhtml=window.document.body.innerHTML;
sprnstr="<!--startprint-->";
eprnstr="<!--endprint-->";
prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+18);
prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
if(oper<10)
{openwindow=window.open('preview.htm',"打印预览","toolbar=no,menubar=no,resizable=yes,status=no,scrollbar=yes");
openwindow.document.body.style.textAlign="center";
window.document.body.innerHTML=prnhtml;
window.print(); }
}
</script>运行的时候总是,在openwindow.document.body.style.textAlign="center";报错,说body不存在,我调试了一下,openwindow.document添加监视还有值,openwindow.document.body就没有了,请问这是为什么,该怎么改??
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货