Advertisement
yacel100

imprimir.js

Dec 13th, 2016
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. /*
  3.  * @Funcion: imprSelec
  4.  * @Params: cls-ocultar --> es el class de lo que
  5.  * se va ocultar en la impresion
  6.  * areaImpresion: Id del div que se va imprimir
  7.  * @Descripcion: Imprime un div de html.
  8.  * @Autor: Jose Luis Yacelly
  9.  * */
  10. function imprSelec(areaImpresion) {
  11.     //$('#' + areaImpresion).printThis();
  12.  
  13.     $('.cls-ocultar').hide();
  14.     var estilos = '';
  15.     $("link[rel=stylesheet]").each(function () {
  16.         var href = $(this).attr("href");
  17.         if (href) {
  18.             var media = $(this).attr("media") || "all";
  19.             estilos = estilos + '<link type="text/css" rel="stylesheet" href="' + href + '" media="' + media + '">';
  20.         }
  21.     });
  22.  
  23.     var ficha = $('#' + areaImpresion);
  24.     var ventimp = window.open(' ', 'popimpr');
  25.     ventimp.document.write('<html><head>' + estilos + '</head><body>');
  26.     ventimp.document.write(ficha.html());
  27.     ventimp.document.write('</body>');
  28.     ventimp.document.write('</html>');
  29.     ventimp.document.close();
  30.     ventimp.print();
  31.     ventimp.close();
  32.     $('.cls-ocultar').show();
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement