打印网页的特定部分 [英] Print specific part of webpage

查看:123
本文介绍了打印网页的特定部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



应用程序有一个用户列表,显示他们的名字和姓氏。

我试图打印我的应用程序的特定部分。当我点击一个用户时,我会看到一个弹出窗口,提供更详细的信息。

我会如何去打印一个用户点击的弹出窗口?
弹出窗口如下所示:

 < div id =user<?= $ user-> id ;?>中类= 弹出 > 
< div class =details>
用户详细信息...
< / div>
< a href =#print>列印< / a>
< / div>

尽管打印按钮还没有工作。

 <$ c $ =h2_lin>解决方案

c> var prtContent = document.getElementById(your div id);
var WinPrint = window.open('','','left = 0,top = 0,width = 800,height = 900,toolbar = 0,scrollbars = 0,status = 0);
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();


I'm trying to print a specific part of my application.

The application has a list of users, displaying their first and last name. When I click a user I get a popup with more detailed information about them.

How would I go about printing just the popup for a user I clicked? The popup looks like this:

 <div id="user<?=$user->id;?>" class="popup">
      <div class="details">
           User details...
      </div>
      <a href="#print">Print</a>
 </div>

The print button isn't working yet though.

解决方案

You can use simple JavaScript to print a specific div from a page.

var prtContent = document.getElementById("your div id");
var WinPrint = window.open('', '', 'left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0');
WinPrint.document.write(prtContent.innerHTML);
WinPrint.document.close();
WinPrint.focus();
WinPrint.print();
WinPrint.close();

这篇关于打印网页的特定部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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