问题描述
我将使用按钮和onclick函数来打印html表.当我尝试执行此操作时,总是提示我一个窗口,然后从那里我必须再次按下按钮调用print.那么只有文档将要发送到打印机.
I'm going to print a html table using a button and onclick function.when i'm trying to do this it is prompt me a window always and from there i have to press again a button call print. then only the document is going to printer.
所以我想要的是一键式打印该表格,并且没有任何打印预览提示,可以这样做吗?如何?
so what i want is to print that table form one button click and without any prompt for print preview, is it possible to do it? and how?
我正在使用此代码来打印表格.
i'm using this code to print the table.
function printlayout() {
var data = '<input type="button" value="Print this page" onClick="window.print()">';
var DocumentContainer = document.getElementById('printlayout');
var WindowObject = window.open('', "TrackHistoryData",
"width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
WindowObject.document.writeln(DocumentContainer.innerHTML);
WindowObject.document.close();
WindowObject.focus();
WindowObject.print();
WindowObject.close();
}
我知道这里有成千上万个与此类似的问题,但没有任何帮助我解决问题的方法.我主要关注Google chrome浏览器来运行我的应用程序.
i know there is thousands of questions here similar to this but nothing helped me to solve my problem.. I mostly focusing the Google chrome browser to run my application.
推荐答案
否,很遗憾,这是不可能的,该功能受浏览器控制,您无法对其进行操作.
No, unfortunately this is not possible, that feature is under control of the browser and you cannot manipulate that.
这篇关于在不提示预览窗口的情况下打印html表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!