Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Print Preview instead of print page

 
Sahana Hegde
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Is there any way in which I can get the print preview of the page using a javascript.

I am using this function now.

Can I get the print preview of this instead of print?

Thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JavaScript just has window.print() out of the box so nope. You could look into ActiveX, but that limits you to IE only.

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64838
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The browser provides print preview (as provided by the print architecture of the underlying OS). Why do you need something more than the browser provides?
 
Sahana Hegde
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If thats not possible then I have another question. When I open the content in the above code in a new window. It keeps loading.The loading of the page does not stop. When I try to go to print preview from the menu it hangs.
Sometimes it does not hang, when I go to print preview gives message "Please try after the page loads"
How can I correct this?
[ December 01, 2008: Message edited by: Sahana Hegde ]
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When the window is hanging are you removing the line myWin.document.close();? That line is important and does not close the browser window.

You should swap the print line too:



to



Eric
 
Sahana Hegde
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried retaining only this code to check if it finishes loading.

Still the same, keeps loading the page.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did not close the document like I said had to be done in my last post.

You need the myWin.document.close() in there.

Eric
 
Sahana Hegde
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
works thanks a lot.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic