print code in js stackoverflow

Solutions on MaxInterview for print code in js stackoverflow by the best coders in the world

showing results for - "print code in js stackoverflow"
Melody
17 Aug 2020
1function print(data, event) {
2                event.preventDefault();
3                printElement(document.getElementById("grid"));
4            };
5
6function printElement (elem) {
7                var domClone = elem.cloneNode(true);
8                var $printSection = document.getElementById("grid");
9                if (!$printSection) {
10                    var $printSection = document.createElement("div");
11                    $printSection.id = "grid";
12                    document.body.appendChild($printSection);
13                } else {
14                    $printSection.innerHTML = "";
15                    $printSection.appendChild(domClone);
16                }
17
18                var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
19                if (is_chrome == true) {
20                    window.print();
21                    if (window.stop) {
22                        location.reload(); //triggering unload (e.g. reloading the page) makes the print dialog appear
23                        window.stop(); //immediately stop reloading
24                    }
25                } else {
26                    window.print();
27                }
28                return false;
29            };
30
Gene
17 Jun 2016
1   <div class="modal-body">
2                <div class="" id="mydata">
3                    <div id="grid">Some Data</div>
4                </div>
5            </div>
6
7<button type="button" id="outageSummary_printBtn" class="btnPrint" data-dismiss="modal" onclick="print()>Print</button>
8