This is the way to print content of a particular div through this function. Very basic but important :
function PrintContent(ctrl) {
var DocumentContainer = ctrl;
var WindowObject = window.open('', "TrackHistoryData",
"width=420,height=225,top=250,left=345,toolbars=no,scrollbars=yes,status=no,resizable=no");
WindowObject.document.write(DocumentContainer.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
You need to put this iframe for better preview..
<iframe id="ifmcontentstoprint" style="height: 0px; width: 0px; position: absolute">
</iframe>
This is function for whole Page :
function printPage() {
var content = document.getElementById("Your Div ID");
var pri = document.getElementById("ifmcontentstoprint").contentWindow;
pri.document.open();
pri.document.write(content.innerHTML);
pri.document.close();
pri.focus();
pri.print();
}
function PrintContent(ctrl) {
var DocumentContainer = ctrl;
var WindowObject = window.open('', "TrackHistoryData",
"width=420,height=225,top=250,left=345,toolbars=no,scrollbars=yes,status=no,resizable=no");
WindowObject.document.write(DocumentContainer.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
You need to put this iframe for better preview..
<iframe id="ifmcontentstoprint" style="height: 0px; width: 0px; position: absolute">
</iframe>
This is function for whole Page :
function printPage() {
var content = document.getElementById("Your Div ID");
var pri = document.getElementById("ifmcontentstoprint").contentWindow;
pri.document.open();
pri.document.write(content.innerHTML);
pri.document.close();
pri.focus();
pri.print();
}
No comments:
Post a Comment