在新标签页面中打开以进行打印

时间:2015-10-19 16:17:02

标签: javascript

我想在新标签页中打开我的打印屏幕选项而不是新窗口。

这是我的javascript代码

$scope.PrintWindow = function(divName,method) {
  var printContents = document.getElementById(divName).innerHTML;
  var popupWin = window.open('Print', method, 'fullscreen=yes');
  popupWin.document.open()
  popupWin.document.write('<html><head><link href="print.css" rel="stylesheet" type="text/css" media="print"></head><body onload="window.print()">' + printContents + '</html>');

  popupWin.document.close();
           popupWin.focus();
} 

_self在同一窗口中打开

_target和_newtab在新窗口中打开。我希望它在新标签中。

1 个答案:

答案 0 :(得分:1)

删除了全屏=是,它解决了我的问题。

  $scope.PrintWindow = function(divName,method) {
      var printContents = document.getElementById(divName).innerHTML;
      var popupWin = window.open('Print', method,);
      popupWin.document.open()
      popupWin.document.write('<html><head><link href="print.css" rel="stylesheet" type="text/css" media="print"></head><body onload="window.print()">' + printContents + '</html>');

      popupWin.document.close();
               popupWin.focus();
    }