开发者

Print several different pages PHP

I want to have a button "Print all reports" which will print 5 diff开发者_运维问答erent URLs at once. Is there a way to do it without making it redirect you to a new page I will have to create with all the code again for each of the URLs and window.print() it?


I think the way you have exposed is good from every angle. Have a different page which prints all code of 5 URLs and call window.print() function to open the print-dialog.

If not, you will have to use ajax to fetch the output of all 5 different URL's and dump it on the same page where the user clicked the button. But, I would oppose this approach since it loses the ability to go back to the page and user could be deceived if they bookmark it.


Well if that's what you want, you can AJAX content of all the five pages into one page and once it's all ready, you can print the single page. If you use jQuery, it will look like this :

    (
  function(){
   $.ajax({url:"url1", success:function(resp){ 
    $("#mydiv").html(resp);
    //make other similar calls for rest of the pages
    //and in your last callback, call window.print()     
   });
    })();

Even if you don't want to use jQuery, you can do it with raw ajax.


using just a browser you write a script that generates 1 url out of 5 urls, and separate the html from each of the urls with this.

<DIV style="page-break-after:always"></DIV>

and then the user can just print out your 1 url and have 5 urls of information.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜