jQuery打印函数使用css打印div内容 [英] jQuery Print function to print div content with css

查看:218
本文介绍了jQuery打印函数使用css打印div内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个功能为我的Wordpress插件使用jQuery打印从div与类table_disp的内容。如何与它一起打印CSS样式。

  function pop_print(){
w = window.open(null,'Print_Page','scrollbars = yes') ;
w.document.write(jQuery('。table_disp')。html());
w.document.close();
w.print();任何想法?

h2_lin>解决方案

您需要在弹出窗口中的父页面中包含您正在使用的SAME样式表。

  var myStyle = 

'< link rel =stylesheethref =http://mysite.com/mystyle.css/>';
w.document.write(myStyle + jQuery('。table_disp')。html());


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?

解决方案

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());

这篇关于jQuery打印函数使用css打印div内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆