window.print() in same window vs new window

问题: Can any one help with this . Case 1: Print in same window. var restorepage = $('body').html(); var printcontent = $('#ctl00_WebPartManager_BlankWP0_CanvasControl_Canva...

问题:

Can any one help with this .

Case 1: Print in same window.

var restorepage = $('body').html();
var printcontent = 
$('#ctl00_WebPartManager_BlankWP0_CanvasControl_Canvas').clone();

$('body').empty().html(printcontent);
window.print();
$('body').html(restorepage);

Output: This is perfect for me , the only thing is after i restore the original controls they dont seem to work . So I am trying to print the same using a new window.

Case 2: Print in a New window

    var w = window.open();
    var printcontent = $('#ctl00_WebPartManager_BlankWP0_CanvasControl_Canvas').clone();
    $(w.document.body).empty().html(printcontent);
    w.focus();
    w.print();
    w.close();

Output : The Images are realigned and even image goes missing. I need the Case1 Output , but in a new window , so as the original window is not modified. enter image description here


回答1:

Yo need create a partial view with all css references and then clone the object in the new window, or maybe you can create an iFrame or dialog in the same page...

  • 发表于 2019-07-05 17:54
  • 阅读 ( 131 )
  • 分类:sof

条评论

请先 登录 后评论
不写代码的码农
小编

篇文章

作家榜 »

  1. 小编 文章
返回顶部
部分文章转自于网络,若有侵权请联系我们删除