print code in js stackoverflow
function print(data, event) {
event.preventDefault();
printElement(document.getElementById("grid"));
};
function printElement (elem) {
var domClone = elem.cloneNode(true);
var $printSection = document.getElementById("grid");
if (!$printSection) {
var $printSection = document.createElement("div");
$printSection.id = "grid";
document.body.appendChild($printSection);
} else {
$printSection.innerHTML = "";
$printSection.appendChild(domClone);
}
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if (is_chrome == true) {
window.print();
if (window.stop) {
location.reload(); //triggering unload (e.g. reloading the page) makes the print dialog appear
window.stop(); //immediately stop reloading
}
} else {
window.print();
}
return false;
};
<div class="modal-body">
<div class="" id="mydata">
<div id="grid">Some Data</div>
</div>
</div>
<button type="button" id="outageSummary_printBtn" class="btnPrint" data-dismiss="modal" onclick="print()>Print</button>
Also in JavaScript:
- how to make a circle in js
- div click outside to hide javascript
- javascript get data-id attribute
- javascript detect mobile or desktop
- <!DOCTYPE html> <!--[if IE 9]> <html lang="" class="js ie9 ... www.tork.cz › product-list www.tork.cz › product-list Cached addEventListener(e,a,!1)})}l(c)}},{}],3:[function(e,n,t){function r(e,n){if(!i)return!1 ... typeof window.performance
- Elements in iteration expect to have 'v-bind:key' directives
- jquery cdm
- screen.render is not a function in node
- how to get textedit on mac without download
- addclass javascript
- how to install reveal.js from node
- if function example
- JSONDecoder
- js if not undefined
- curl post file json
- This version of CLI is only compatible with Angular versions ^9.0.0-beta || >=9.0.0 <10.0.0, but Angular version 8.1.3 was found instead.
- get domain name javascript
- how to compare two strings in javascript if condition
- Accessing user input through js
- loop through api response in react
- javascript number format
- react background image
- javascript clear style inline property
- console.log ejs