< body onload =" window.print(); window.close()的;"> [英] <body onload="window.print(); window.close();">

查看:129
本文介绍了< body onload =" window.print(); window.close()的;">的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个订单表单,用户javascript在客户点击打印页面时创建一个新的html

文档。按钮。


创建新文档后,然后打印文档并使用以下代码关闭它:


< body onload =" window.print(); window.close();">


这个工作正常(或者至少我期望它在MS下工作的方式

Internet Explorer,但是它会让Netscape陷入崩溃状态


有没有人能解释为什么?


提前谢谢你,


Stephen

I have created an order form that users javascript to create a new html
document when the customers clicks the "print page" button.

Once the new document has been created it then prints the document and
closes it with the following code:

<body onload="window.print(); window.close();">

This works correctly (or at least the way I expect it to work under MS
Internet Explorer, but it cuases Netscape to "crash"

Does anyone have an explanation as to why?

Thank you in advance,

Stephen

推荐答案

st ***** @ ploughbooksales.com.au 写道:
st*****@ploughbooksales.com.au wrote:
< body onload =" window.print(); window。 close();">

这个工作正常(或至少我希望它在MS / Internet Explorer下工作的方式,但它会让Netscape陷入崩溃

有没有人解释为什么?
<body onload="window.print(); window.close();">

This works correctly (or at least the way I expect it to work under MS
Internet Explorer, but it cuases Netscape to "crash"

Does anyone have an explanation as to why?




你试图关闭显示你想要的文件的窗口

打印。

PointedEars



You are trying to close the window that displays the document you want to
print.
PointedEars


st ***** @ ploughbooksales.com.au 写道:
我创建了一个订单表单,用户javascript创建一个新的html
当客户点击打印页面时记录文档。按钮。

创建新文档后,它将打印文档并使用以下代码关闭它:

< body onload =" window 。打印(); window.close();">

这个工作正常(或者至少我期望它在MS / Internet Explorer下工作的方式,但它会让Netscape陷入崩溃状态。
I have created an order form that users javascript to create a new html
document when the customers clicks the "print page" button.

Once the new document has been created it then prints the document and
closes it with the following code:

<body onload="window.print(); window.close();">

This works correctly (or at least the way I expect it to work under MS
Internet Explorer, but it cuases Netscape to "crash"




我在Firefox 1.5中的测试似乎表明window.print是异步的
;也就是说,脚本不会等待对话框在继续之前关闭

的框。例如,如果你将onload

处理程序更改为以下内容:


< body onload =" window.print(); alert(''foo'');">


....然后Firefox将显示foo警报首先,然后是打印

对话框。


不幸的是,似乎window.print从未成为任何一部分

正式规范,因此询问同步或异步是否是正确行为是没有意义的。但是,它是非常明显的不管怎样,它不应该'能够使

浏览器崩溃。


- David



My testing in Firefox 1.5 seems to indicate that window.print is
asynchronous; that is, the script does not wait for the dialog box to
be closed before continuing. For example, if you change your onload
handler to the following:

<body onload="window.print(); alert(''foo'');">

....then Firefox will show the "foo" alert first, and then the Print
dialog.

Unfortunately, it seems that window.print has never been part of any
formal specification, so it''s meaningless to ask whether being
synchronous or asynchronous is the "correct" behavior. However, it''s
pretty obvious that no matter what, it shouldn''t be able to crash the
browser.

-- David


谢谢你的解释。


所以有没有办法在文件打印后关闭文件,或者

我只能留下它有一个神器让客户关闭。


Stephen

Thanks for the explanations.

So is there a way of closing the document after it has been printed, or
can I only leave it there is an artifact for the customer to close.

Stephen


这篇关于&lt; body onload =&quot; window.print(); window.close()的;&QUOT;&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆