javascript - Print a distant page in JS, JQ, or Angular -
i have pages have print, when launch printing, preview ugly , can't select , modify elements want (there's few elements want print, , others hide printing).
i don't succeed less (with @media print
), made template , inject inside elements want show printing (with angularjs). problem original page http://example.com/id/page-name/?tab=media
. put in script listener catch print event , redirect user on http://example.com/id/page-name/?tab=media&print=true
.
then timeout launches printing script (window.print()
), , when user leave printing page, script redirects him http://example.com/id/page-name/?tab=media
.
the problem makes lot of closing/opening windows, , may uncomfortable user. think solution weird , awkward, found nothing else it...
so have solution print distant page, not make lot of closing/opening frames?
for example, when ctrl+p
on http://example.com/id/page-name/?tab=media
, prints http://example.com/id/page-name/?tab=media&print=true
page, , not original ?
a thing document.location.href="http://example.com/id/page-name/?tab=media&print=true".print();
or print('http://example.com/id/page-name/?tab=media&print=true');
?
i hope it's possible!
you can idea question angularjs ui tab print selected contend tab , create print function like
$scope.print = function (divname) { var printcontents = document.getelementbyid(divname).innerhtml; var popupwin = window.open('', '_blank', 'width=800,height=700'); popupwin.document.open() popupwin.document.write('<html><head><link rel="stylesheet" type="text/css" href="style.css" /></head><body onload="window.print()">' + printcontents + '</html>'); popupwin.document.close(); }
Comments
Post a Comment