0

Hi all,

I want to print a page from another page. I have a master page with links to other page. When I click "print," it should print the another page.
The function window.print() is printing only the active page. So on click print i am opening a new window.

In the onload event of the target page i have used
<body onload="window.focus();window.print();window.close ();">

Eventhough it's working, at the same time the window is also popping up behind the printer set up screen. when i click print or cancel the window gets closed automatically.
i don't want the window to pop up. Do suggest me if there is any other alternative way..

Thanks for your help.

2
Contributors
2
Replies
5
Views
7 Years
Discussion Span
Last Post by help_lucky
0

I think the page has to be open before you print it - but you can use an invisible iframe (cheat):

<script type="text/javascript">
function printPage(iFid){
iFid.focus();
iFid.print();
}
</script>
<style>
#iframe1{
visibility:hidden;
}
</style>
</head>
<body>
<iframe name="iframe1" id="iframe1" width="1" height="1" src="index.php"></iframe>
<a value="print page" href="javascript:printPage(iframe1);">print page</a>
</body>
</html>

I got this idea from here and just tinkered with it.

Edited by happygeek: fixed formatting

0

That's good idea. It worked for me. Thanku for your time and for detailed response.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.