Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.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 window.print包含的文本区域值_Javascript_Html - Fatal编程技术网

Javascript window.print包含的文本区域值

Javascript window.print包含的文本区域值,javascript,html,Javascript,Html,我正在尝试打印一个html页面,它工作得非常好,但是我缺少这些值​​打印时是否在文本区域内 如何包含这些值​​文本区域的名称 以下是打印功能的代码: function print(section) { var printWindow = window.open('', '', 'height=600,width=800'); printWindow.document.write('<html><head><title>Navigationl

我正在尝试打印一个html页面,它工作得非常好,但是我缺少这些值​​打印时是否在文本区域内

如何包含这些值​​文本区域的名称

以下是打印功能的代码:

  function print(section) {
    var printWindow = window.open('', '', 'height=600,width=800');
    printWindow.document.write('<html><head><title>Navigationlog</title>');

            //Print the Table CSS.
            var table_style = document.getElementById("table_style").innerHTML;
            printWindow.document.write('<style type = "text/css">');
            printWindow.document.write(table_style);
            printWindow.document.write('</style>');
            printWindow.document.write('</head>');
    
            //Print the DIV contents i.e. the HTML Table.
            printWindow.document.write('<body>');
            var divContents = document.getElementById(section).innerHTML;
            printWindow.document.write(divContents);
            printWindow.document.write('</body>');
    
            printWindow.document.write('</html>');
            printWindow.print();
            printWindow.close();;
  }
功能打印(部分){
var printWindow=window.open(“”,’高度=600,宽度=800’);
printWindow.document.write('Navigationlog');
//打印表格CSS。
var table_style=document.getElementById(“table_style”).innerHTML;
printWindow.document.write(“”);
printWindow.document.write(表格样式);
printWindow.document.write(“”);
printWindow.document.write(“”);
//打印DIV内容,即HTML表。
printWindow.document.write(“”);
var divContents=document.getElementById(section.innerHTML);
printWindow.document.write(divContents);
printWindow.document.write(“”);
printWindow.document.write(“”);
printWindow.print();
printWindow.close();;
}
以下是完整的示例代码:


@媒体印刷品{
身体{
变换:缩放(.97);
高度:适合的内容;
宽度:自动;
位置:绝对位置;
排名:0;
左:0;
右:0;
}
文本区{
字体大小:1.0vw;
}
#可路由td{
字体大小:1.0vw;
}
#可路由th{
字体大小:1.0vw;
}
}
html{
字体系列:Arial、Helvetica、无衬线字体;
位置:固定;
排名:0;
底部:0;
左:0;
右:0;
溢出y:自动;
/*用于调试*/
}
身体{
字体系列:Arial、Helvetica、无衬线字体;
位置:固定;
排名:0;
底部:0;
左:0;
右:0;
溢出y:自动;
/*用于调试*/
}
/*设置选项卡内容的样式*/
.网页内容{
显示:无;
}
/*导航日志*/
tr{
垂直对齐:中间对齐;
垫面:0.5vw;
垫底:0.5vw;
边界塌陷:塌陷;
}
th{
垂直对齐:中间对齐;
垫面:0.5vw;
垫底:0.5vw;
文本对齐:左对齐;
边界塌陷:塌陷;
}
运输署{
文本对齐:左对齐;
垂直对齐:顶部;
填充:0.3vw;
边界塌陷:塌陷;
}
#左{
背景:线性渐变(右上角,357987,35798749%,黑色49%,黑色51%,透明51%,透明);
}
#对{
背景:线性渐变(右下角,357987,35798749%,黑色49%,黑色51%,透明51%,透明);
}
桌子{
宽度:100%!重要;
字体系列:Arial、Helvetica、无衬线字体;
垂直对齐:中间对齐;
边界间距:0;
边界塌陷:塌陷;
背景色:白色;
颜色:白色;
}
文本区{
字体系列:Arial、Helvetica、无衬线字体;
边界:无;
宽度:100%;
身高:100%;
背景色:透明;
调整大小:无;
大纲:无;
字体大小:2vw;
垂直对齐:中间对齐;
文本对齐:居中;
填充:0;
}
#可路由td{
边框:0.2vw纯黑;
字体大小:1.4vw;
文本对齐:居中;
垂直对齐:中间对齐;
}
#可路由th{
边框:0.2vw纯黑;
字体大小:1.4vw;
文本对齐:居中;
}
#可路由tr{
边框:0.2vw纯黑;
}
#路由表{
表布局:固定;
显示:内联块;
溢出包装:断开单词;
最大宽度:100%;
}
p{
显示:块;
边缘块启动:0.2vw;
边缘块端:0.2vw;
保证金内联开始:0vw;
边距内联端:0vw;
字体大小:粗体;
垫面:0.5vh;
垫底:0.5vh;
颜色:黑色;
}
#工具栏{
显示器:flex;
证明内容:周围的空间;
背景色:#035869;
调整项目:灵活启动;
调整内容:灵活启动;
填充:0.5VH0;
}
#文件控制{
高度:30px;
填充:0.5VH0;
左侧填充:1vh;
}
#保存,
#印刷品,
#以前,,
#下一个{
字体大小:大号;
字体系列:Verdana;
背景色:357987;
颜色:白色;
文本对齐:居中;
光标:指针;
身高:100%;
宽度:15vw;
大纲:无;
边框:2倍纯白;
裕度:0.5vh;
}
#保存:悬停,
#打印:悬停,
#上一篇:悬停,
#下一步:悬停{
字体大小:较大;
}
印刷品
航海日志
飞机登记:
日期:
机长:
var openNavlog=openPage('Navlog');
函数openPage(第页){
//声明所有变量
var i,页面内容;
//使用class=“tabcontent”获取所有元素并隐藏它们
pagecontent=document.getElementsByCassName(“pagecontent”);
对于(i=0;ifunction print(section) {
       var textArea1 = document.getElementById('1').value;
       var textArea2 = document.getElementById('2').value;
       var textArea3 = document.getElementById('3').value;
        var printWindow = window.open('', '', 'height=600,width=800');
        printWindow.document.write('<html><head><title>Navigationlog</title>');

                //Print the Table CSS.
                var table_style = document.getElementById("table_style").innerHTML;
                printWindow.document.write('<style type = "text/css">');
                printWindow.document.write(table_style);
                printWindow.document.write('</style>');
                printWindow.document.write('</head>');
        
                //Print the DIV contents i.e. the HTML Table.
                printWindow.document.write('<body>');
                var divContents = document.getElementById(section).innerHTML;
                printWindow.document.write(divContents);
                printWindow.document.write('</body>');
        
                printWindow.document.write('</html>');
                printWindow.document.getElementById('1').value = textArea1;
                printWindow.document.getElementById('2').value = textArea2;
                printWindow.document.getElementById('3').value = textArea3;
                printWindow.print();
                printWindow.close();
      }