I would like to be able to print a div with overflow:auto
by clicking a开发者_运维问答 link. Below is the code I am working with but it dose it on page load...
printMe=window.open();
printMe.document.write($('.terms_and_conditions').html());
printMe.print();
printMe.close();
You can wrap it in click
event like:
$(function(){
$('#element_id').click(function(){
printMe=window.open();
printMe.document.write($('.terms_and_conditions').html());
printMe.print();
printMe.close();
});
});
Try to use CSS print, an example like this:
@media print {
table, #MenuDiv, {
visibility: hidden;
}
.fd_window, infoHide, #selectedItems, .fd_body {
border: 0px solid;
width: 100%;
}
#selectedItems table {
visibility: visible!important;
color: #000;
display: block !important;
position: absolute;
left: 0;
top: 0;
height: 100%;
width: 8.5in;
}
#selectedItems table th, #form_selectedItems table td {
border: 1px solid #000;
padding: 3px;
vertical-align: top;
}
}
精彩评论