tags:

views:

28

answers:

3

Hi guys, Need to make a function that would open a popout with a div inheriting innerhtml from another div on that page.

For example, the initial div might have some sort of a table, therefor when the user presses the print button, this div would open in a new popout. :)

EDIT:

Thanks, got it working!

function opentrint(  ) { 

var $toprint = $('#divToPrint').html();
myWin=window.open('','myWin','menubar,scrollbars,left=30px,top=40px,height=400px,width=600px');
myWin.document.write($toprint); 

}
+1  A: 

use var printwindow = window.open('file', 'uniqueid', 'width=400, height=300');

to open a new window. That script that you're calling in file should be able to access the opener window by var div = window.opener.getElementById('divid');

It should be possible to wrap window.opener in a jQuery object. You might even need to use $(window.opener).contents().find('#divid');.

jAndy
+1  A: 

you might want to check out this plugin: http://plugins.jquery.com/project/jqPrint

it allows you to print specific parts of a page. then you don't have to deal with pop-outs and such.

Patricia
+1  A: 

The best way to go about this is to first make sure you don't get what you want from print stylesheet before using a plugin.

First try to alter the page CSS using an alternative stylesheet that has media="print" that way for example you can make the page black and white or take some images you dont need the print sheet off

XGreen