tags:

views:

216

answers:

4

can we print separate html pages with one click

A: 

No.

But you can create a new page that holds the contents of each page you want to print perhaps using media selectors to only show a summary on the screen), and the print that page in two clicks (one click to open the print dialog and another to click "Ok").

[update]: As I think about it more, you could probably use javascript to load the pages as popups and then open the print dialog for each of the loaded pages. That's not going to be a very nice experience for the user, though.

Joel Coehoorn
+1  A: 

Try using a specific CSS for print mode.

<link rel="stylesheet" type="text/css" media="print" href="print.css">

source: http://www.javascriptkit.com/dhtmltutors/cssmedia.shtml

Chris Ballance
A: 

I know that Internet Explorer has the option in the print options to print this page as well as all linked pages. You could create a single page of links to all the pages you want and then print that with that setting turned on.

nickf
A: 

I think it is possible, but not sure about portability. I was developing a rich intranet application that would run under Internet Explorer (hence I don't know about its portability) and used a function like this:

printHtml = function(html){
  var frame = top.document.getElementById(IFRAME_ID);
  if (!frame) {
    frame = top.document.createElement('IFRAME');
    frame.id = IFRAME_ID;
    frame.style.width = '1px';
    frame.style.height = '1px';
    top.document.body.appendChild(frame);

    frame.contentWindow.document.open();
    frame.contentWindow.document.write('<html><head>');
    frame.contentWindow.document.write('<link type="text/css" rel="StyleSheet" media="all" href="style.css"/>');
    frame.contentWindow.document.write(
        '</head><body onload="window.focus();window.print();top.document.body.removeChild(top.document.getElementById(\''
            + IFRAME_ID + '\'));">');
    frame.contentWindow.document.write(html);
    frame.contentWindow.document.write('</body></html>');
    frame.contentWindow.document.close();
  }
};

I guess, you could create iframes and print them any number of times, although print options dialog will be displayed for every page.

Eugene Morozov