JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
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  
Old August 22nd, 2003, 08:25 AM
lpa lpa is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 4 lpa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old August 22nd, 2003, 08:33 AM
dhouston's Avatar
dhouston dhouston is offline
Contributing User
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: May 2003
Location: Tennessee
Posts: 1,355 dhouston User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via ICQ to dhouston
Maybe try self.close()?

Reply With Quote
  #3  
Old August 22nd, 2003, 09:38 AM
lpa lpa is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 4 lpa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Erf...

With IE 6 it don't work but with Mozilla, it's nice

Thanx for your help

Reply With Quote
  #4  
Old August 23rd, 2003, 10:15 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
The window will only close after the user has finished with the Print dialog box process. You cannot force a page to be printed.

Reply With Quote
  #5  
Old August 23rd, 2003, 01:03 PM
lpa lpa is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 4 lpa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
I don't want to force the printing operation but only the close operation

Reply With Quote
  #6  
Old August 24th, 2003, 02:33 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 6 m 11 sec
Reputation Power: 8
Send a message via ICQ to stumpy Send a message via MSN to stumpy
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.).

Reply With Quote
  #7  
Old August 24th, 2003, 03:27 AM
lpa lpa is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Posts: 4 lpa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #8  
Old April 18th, 2008, 10:24 PM
mcm mcm is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 1 mcm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 m 24 sec
Reputation Power: 0
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>

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Close a popup after print


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway