Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/cocoa/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在新选项卡中打开,以便打印_Javascript - Fatal编程技术网

Javascript 在新选项卡中打开,以便打印

Javascript 在新选项卡中打开,以便打印,javascript,Javascript,我想在新选项卡而不是新窗口中打开“打印屏幕”选项 这是我的javascript代码 $scope.PrintWindow = function(divName,method) { var printContents = document.getElementById(divName).innerHTML; var popupWin = window.open('Print', method, 'fullscreen=yes'); popupWin.document.open()

我想在新选项卡而不是新窗口中打开“打印屏幕”选项

这是我的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();
} 
$scope.PrintWindow=函数(divName,方法){
var printContents=document.getElementById(divName).innerHTML;
var popupWin=window.open('Print',方法,'fullscreen=yes');
popupWin.document.open()文件
popupWin.document.write(“”+打印内容+“”);
popupWin.document.close();
popupWin.focus();
} 
_self在同一窗口中打开


_目标和新选项卡将在新窗口中打开。我希望它位于新选项卡中。

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

  $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();
    } 
$scope.PrintWindow=函数(divName,方法){
var printContents=document.getElementById(divName).innerHTML;
var popupWin=window.open('Print',method,);
popupWin.document.open()文件
popupWin.document.write(“”+打印内容+“”);
popupWin.document.close();
popupWin.focus();
} 

您不能强制创建新选项卡,而不能强制创建新窗口,因为这取决于浏览器和可能的用户设置。这一点已经讨论过了。我一直在使用fullscreen=yes打开新窗口。感谢您的努力。