Help - Search - Members - Calendar
Full Version: Printing another page
Weborum Webmaster Forum > Web Page Design > Javascript
leir

Anybody can help?

This is the scenario:

Page1 contains a link "print". Once you've clicked the link, page2 will be printed out.

Would that be possible?

What i have now is this line of code:

QUOTE
<div align="center"><a href="javascript:window.print();">print</a> </div>


But I wanted that line to be in Page1 then the page that will be printed is page2. And the data in page2 is no need to be displayed. Meaning once u've clicked the link, it will automatically print that page (page2).

What would be the proper code?

Please help. Thanks



bassrek
Hey, leir. I've had to do stuff like this before, and this is the best solution I've been able to come up with.

My source page has a very simple javascript function:
CODE

function openwin(where) {
window.open(where,"TempWindow","width=300,height=210,resizable=yes,status=yes")
}


With a link somewhere in the page:
CODE

<a href="javascript:openwin('YourPage.htm')">Click me!</a>


And on the page you're linking to, add this code to the body tag:
CODE

<body on_load="javascript:window.print();window.close();">

It's not entirely seamless; the user will see the popup and the print dialogue, but as soon as the click the button on the dialogue, the pop-up will close.

Note: take out the underscore (_) in the on_load function. The forum strips out the code as a safety measure smile.gif

Willy probably has a better solution than mine, and seeing as this isn't really ASP-releated, I'm going to move this to the javascript forum.
leir
Thanks a lot bassrek. thumbsupsmileyanim.gif
bassrek
Does that work for you then, leir?
leir
Yup it does!

Thanks. specool.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.