Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery Print function to print div content with css

I've this function for my Wordpress plugin uses jQuery that prints the content from the div with class "table_disp". How can I print the css style along with it.

function pop_print(){
    w=window.open(null, 'Print_Page', 'scrollbars=yes');        
    w.document.write(jQuery('.table_disp').html());
    w.document.close();
    w.print();
}

Any idea?

like image 386
Gurjot Bhatti Avatar asked Jul 19 '13 18:07

Gurjot Bhatti


1 Answers

You need to include the SAME stylesheet you're using in the parent page within the pop-up. You may want to make a dummy page stub/wrapper that has your stylesheet in it, then inject your HTML.

var myStyle = '<link rel="stylesheet" href="http://mysite.com/mystyle.css" />';
w.document.write(myStyle + jQuery('.table_disp').html());
like image 181
Diodeus - James MacFarlane Avatar answered Sep 22 '22 09:09

Diodeus - James MacFarlane