// <--- --------------------------------------------------------------------------------------- ---- // Blog Entry: // Ask Ben: Print Part Of A Web Page With jQuery // Author: // Ben Nadel / Kinky Solutions // Link: // http://www.bennadel.com/index.cfm?event=blog.view&id=1591 // Date Posted: // May 21, 2009 at 9:10 PM // ---- --------------------------------------------------------------------------------------- ---> // Create a jquery plugin that prints the given element. jQuery.fn.print = function(){ // NOTE: We are trimming the jQuery collection down to the // first element in the collection. if (this.size() > 1){ this.eq( 0 ).print(); return; } else if (!this.size()){ return; } var chart = $(this).closest('div.quintile-outer-container').find('div.jqplot-target'); // var imgelem = chart.jqplotToImageElem(); var imageElemStr = chart.jqplotToImageElemStr(); // var statsrows = $(this).closest('div.quintile-outer-container').find('table.stats-table tr'); var statsTable = $('
').append($(this).closest('div.quintile-outer-container').find('table.stats-table').clone()); // var rowstyles = window.getComputedStyle(statsrows.get(0), ''); // ASSERT: At this point, we know that the current jQuery // collection (as defined by THIS), contains only one // printable element. // Create a random name for the print frame. var strFrameName = ("printer-" + (new Date()).getTime()); // Create an iFrame with the new name. var jFrame = $( "