dizzy1 Posted February 19, 2009 Share Posted February 19, 2009 Hi all i want to do is print another page Im on one page click a button which passes variables accross: <a href="PersonReportPrint.php?PersonID=1&Module=<?=$ModuleNo;?>&Tyear=<?=$Tyear;?>"> On the other page i have <body onLoad="window.print()"> which opens the print dialogue BUT it also opens that page PersonReportPrint.php when all i want is for that page to print. Link to comment https://forums.phpfreaks.com/topic/146028-print/ Share on other sites More sharing options...
gethinw Posted February 20, 2009 Share Posted February 20, 2009 You could try onLoad='window.print();window.close();' but for that to work the window would have to have been opened by a script in the first place (in firefox at least, not sure about ie), so you'd have to use something like <a onclick='window.open(your url)'> rather than <a href=...> I'd find that behaviour fairly annoying if I was using it though... Link to comment https://forums.phpfreaks.com/topic/146028-print/#findComment-767042 Share on other sites More sharing options...
dizzy1 Posted February 20, 2009 Author Share Posted February 20, 2009 You could try onLoad='window.print();window.close();' but for that to work the window would have to have been opened by a script in the first place (in firefox at least, not sure about ie), so you'd have to use something like <a onclick='window.open(your url)'> rather than <a href=...> I'd find that behaviour fairly annoying if I was using it though... Ill try it see how annoyin it is, thanks. Link to comment https://forums.phpfreaks.com/topic/146028-print/#findComment-767189 Share on other sites More sharing options...
dizzy1 Posted February 20, 2009 Author Share Posted February 20, 2009 right ive added teh code so it opens in it own small window BUT when i do this echo"<body onLoad='window.print()window.close();'>"; It Does Nothing If i Do this echo"<body onLoad='window.print()'>"; IT PRINTS OR echo"<body onLoad='window.close();'>"; IT Closed the window straight away. Link to comment https://forums.phpfreaks.com/topic/146028-print/#findComment-767206 Share on other sites More sharing options...
darkfreaks Posted February 22, 2009 Share Posted February 22, 2009 try: <body onload="window.print();" onunload="window.close();"> Link to comment https://forums.phpfreaks.com/topic/146028-print/#findComment-768074 Share on other sites More sharing options...
dizzy1 Posted February 22, 2009 Author Share Posted February 22, 2009 try: <body onload="window.print();" onunload="window.close();"> Just tried it and no luck, it just simpily prints and doesnt close. Link to comment https://forums.phpfreaks.com/topic/146028-print/#findComment-768085 Share on other sites More sharing options...
darkfreaks Posted February 22, 2009 Share Posted February 22, 2009 function printWin() { window.print(); setTimeout("window.close()",100); } <body onLoad="printWin()"> Link to comment https://forums.phpfreaks.com/topic/146028-print/#findComment-768095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.