使用javascript打印潜水内容时,为什么不在IE中打开“打印”对话框?

使用javascript打印潜水内容时,为什么不在IE中打开“打印”对话框?,javascript,jquery,Javascript,Jquery,我想使用javascript和jquery并使用以下代码打印潜水内容: n = window.open('M80Print.aspx', '_blank', 'status=no,toolbar=no,menubar=yes,height=400px,width=640px'); n.document.write($('#<%=Print.ClientID %>').html()); n.print(); n=window.open('M8

我想使用javascript和jquery并使用以下代码打印潜水内容:

 n = window.open('M80Print.aspx', '_blank', 'status=no,toolbar=no,menubar=yes,height=400px,width=640px');
          n.document.write($('#<%=Print.ClientID %>').html());
          n.print();
n=window.open('M80Print.aspx','u blank','status=no,toolbar=no,menubar=yes,height=400px,width=640px');
n、 document.write($('#').html();
n、 打印();
它在Fire Fox和Chrome中工作,但在IE中未打开打印对话框。 我使用IE8。怎么办?

IE要求您在写入文档之前打开文档,然后在打印之前关闭文档:

n.document.open();
n.document.write($('#<%=Print.ClientID %>').html());
n.document.close();
n.print();
n.document.open();
n、 document.write($('#').html();
n、 document.close();
n、 打印();

IE9测试也应该与IE8一起使用。

它在任何浏览器中都不起作用。Fire fox、IE8和chrome。当打印对话框打开时,窗口关闭。请单击“打印”按钮。窗口没有关闭,所以它是代码中的其他内容-请发布更多代码,我们会看到。这是我的全部代码:
函数printDiv(){n=Window.open('M80Print.aspx','u blank','status=no,toolbar=no,menubar=yes,height=400px,width=640px');n.document.write($('.#').html());n.close();n.print();
您在尝试打印之前关闭窗口,您希望它如何保持打开状态?无论如何,请将
n.close();
移到
n.print();
之后。您还缺少函数的结束括号。谢谢您的帮助。现在它在所有浏览器中都能工作。这是我的代码:
函数printDiv(){n=window.open('M80Print.aspx','u blank','status=no,toolbar=no,menubar=yes,height=400px,width=640px');n.document.open();n.document.write($('.#').html());n.document.close();n.print()}