|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Close a popup after print
Hello,
I have a page which open a popup to print an article. I want to close it immediatly after printing.. Then I^have this code at the end of the page : <script language="JavaScript"> window.print(); window.close(); </script> but this code don't close the popup. Could you help me Thanx |
|
#2
|
||||
|
||||
|
Maybe try self.close()?
|
|
#3
|
|||
|
|||
|
Erf...
With IE 6 it don't work but with Mozilla, it's nice ![]() Thanx for your help |
|
#4
|
||||
|
||||
|
The window will only close after the user has finished with the Print dialog box process. You cannot force a page to be printed.
|
|
#5
|
|||
|
|||
|
I don't want to force the printing operation but only the close operation
![]() |
|
#6
|
||||
|
||||
|
Yeah - sorry, my point is, you have no way of knowing what action the user took with the print dialog. And you cannot do anything until that dialog is closed (whether they printed or not.).
|
|
#7
|
|||
|
|||
|
It's strange :
- my code works on Mozilla, Crazy Browser (which use IE API) but no on IE ![]() - If i set the code in the OnLoad method it works fine, but as I use template,... i must put the code on the bottom of the file.. May be an IE 6 bug |
|
#8
|
|||
|
|||
|
The problem is that unlike Firefox which stops processing the javascript until the print dialog is finished, IE continues to process the rest of the javascript. So when it goes to close the window it can't because of the modal popup (the print dialog). The solution I've come up with is to close the window when it gets focused, which will happen when the print dialog is closed.
Code:
<script type="text/javascript">
window.print();
window.onfocus = function() { window.close(); }
</script>
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > JavaScript Development > Close a popup after print |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|