html 通过网络测试epos-print
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 通过网络测试epos-print相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>ePOS-Print</title>
<script type="text/javascript">
// URL of ePOS-Print supported TM printer (Version 4.1 or later)
var url = 'http://10.0.0.201/cgi-bin/epos/service.cgi';
// URL of ePOS-Print supported TM printer
// var url = 'http://10.0.0.201/cgi-bin/epos/service.cgi?devid=local_printer&timeout=10000';
function button1_Click() {
// Create print document (Version 4.1 or later)
var req =
'<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">' +
'<s:Header>' +
'<parameter xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">' +
'<devid>local_printer</devid>' +
'<timeout>10000</timeout>' +
'<printjobid>ABC123</printjobid>' +
'</parameter>' +
'</s:Header>' +
'<s:Body>' +
'<epos-print xmlns="http://www.epson-pos.com/schemas/2011/03/epos-print">' +
'<pulse drawer="drawer_1" time="pulse_100" />' +
'<text lang="en" smooth="true">Intelligent Printer </text>' +
'<barcode type="ean13" width="2" height="48">201234567890</barcode>' +
'<feed unit="24"/>' +
'<image width="8" height="48">8PDw8A8PDw/w8PDwDw8PD/Dw8PAPDw8P8PDw8A8PDw/w8PDwDw8PD/Dw8PAPDw8P</image>' +
'<cut/>' +
'</epos-print>' +
'</s:Body>' +
'</s:Envelope>';
// Send print document
var xhr = new XMLHttpRequest();
xhr.open('POST', url, true);
xhr.setRequestHeader('Content-Type', 'text/xml; charset=utf-8');
xhr.setRequestHeader('If-Modified-Since', 'Thu, 01 Jan 1970 00:00:00 GMT');
xhr.setRequestHeader('SOAPAction', '""');
xhr.onreadystatechange = function () {
// Receive response document
if (xhr.readyState == 4) {
// Parse response document
if (xhr.status == 200) {
// alert(xhr.responseXML.getElementsByTagName('response')[0].getAttribute('success'));
}
else {
alert('Network error occured.');
}
}
};
xhr.send(req);
}
//
</script>
</head>
<body>
<div style="text-align: center;">
<button onclick="button1_Click()">Print</button>
</div>
</body>
</html>
以上是关于html 通过网络测试epos-print的主要内容,如果未能解决你的问题,请参考以下文章