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. Quote Link to comment 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... Quote Link to comment 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. Quote Link to comment 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. Quote Link to comment 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();"> Quote Link to comment 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. Quote Link to comment 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()"> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.