问题
I have a lot of DIVs having some data in my web page & I want to print a data of a specific div by using "window.print()" without opening any popup. What should I do?
回答1:
You must use CSS Media Types like this:
@media print {
#printable {
display:block;
overflow: visible;
}
#nonprintable {
display:none;
}
}
@media screen {
body, table, tr, td { font:12px Arial, Helvetica, sans-serif; }
.divStyles {
width:850px;
height:150px;
border: 1px solid #000;
background-color: #ccc;
padding: 15px;
}
}
I have created an example for you, see a demo: http://jsfiddle.net/rathoreahsan/Vuw6D/3/
来源:https://stackoverflow.com/questions/6454046/printing-data-inside-a-div