javascript - Printing Issue in Chrome -
I have Google Chrome version 34.0.1847.116. I am using the following code for printing
$ ('# print'). Live ("click", function () {var url = baseUrlReports + "******** **********" var txnwindow = window.open (url, ""); txnwindow .print (); txnwindow.focus ();}); Chrome is hanging at the loading preview at this time. Then all of my JS stopped answering and I can not refresh the page. There is no other option to shut the window. Can someone tell me what is the problem really? The same code is working well on Firefox and IE.
OK, so I have the same problem
Interested in watching - you can find it here and reproduce it: (Just close the print pop-up in Chrome, do not use the "Print" or "Close" button, just close a window)
So here's my solution (I'm not calling window.print () in Chrome originally)
// start the browser detection section var isOpera = !! Window.opera || Navigator.userAgent.indexOf ('OPR /') & gt; = 0; // Opera 8.0+ (UA address for detecting bright / V8-powered opera) var is Firefox = TypStraft installer! == 'undefined'; // Firefox 1.0+ var Safari = Object.prototype.tastingcoll (window.html). Indexoff ('constructor') & gt; 0; // Less Safari 3+: "[Object HTMLElementConstructor]" is Chrome = !! Window. Chrome & amp; Amp; ! IsOpera; // Chrome1+ var isIE = False || !! Document.documentMode; // At least IE 6 / End browser Disclosure section / user click on some $ ('a [href = "# print"]'). ("Click", function () {var data = "& lt; div> Many HTML codes with a JX call & lt; / div & gt;"; CreateWindow (data);}); Functions CreateWindow (data) {var mywindow = window.open ('about: blank', '_blank'); Var myWindowContents = '& lt; Html & gt; + '& Lt; Principal & gt; + '& Lt; Title & gt; Results & lt; / title> + '& Lt; link href = "http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel = "stylesheet" type = "text / css" & gt; + '& Lt; / head & gt; + '& Lt; Body & gt; + Data + '& lt; script src = "http://code.jquery.com/jquery-2.1.0.min.js type =" text / javascript "& gt; ' + '& Lt;' + '/ Script & gt;' + '& Lt; script type = "text / javascript" & gt;' + '$ (Document) .ready (function () {' + '});' + '& Lt;' + '/ Script & gt;' + '& lt; / body & gt;' + '& Lt; / html & gt;'; mywindow.document.write (myWindowContents); mywindow.document.close (); mywindow.focus (); if (! Inc chrome) {mywindow.print ();}} You can see my code here :
This is the best solution I was able to find so far.
Comments
Post a Comment