页面A中的一个按钮单击事件:(弹出页面B,用于打印)
function printAll()
{
var str="<html><head><title></title></head><body>";
str=str + "<input type='button' with='30' name='btnprint' value='打印' onclick=document.all.btnprint.style.display='none';window.print();></body></html>";var ss=window.open("","print"); 
ss.document.write(str);
}问题是:在弹出的页面B中,单击按钮btnprint,这个按钮可以隐藏但没有弹出打印窗口。经测试刷新页面后,会自动弹出打印窗口。我尝试过直接将str中的html放到页面中执行,点击按钮是可以弹出打印窗口的,所以我怀疑是和document.write有关。