TypeError: Cannot read properties of undefined (reading 'send')

// Expert user has replied.
E Efkan YILMAZ 1 year 9 months ago
31 2 0

I am trying to print labels on the Zebra printer using BrowserPrint from the asp page. the below sample code is provided by BrowerPrint, which is working well on Edge in Internet Explorer mode but the same code not working on Edge. Please help with this
The error message is Error in Printing TypeError: Cannot read properties of undefined (reading 'send')

var selected_device;
var devices = [];

function setup() {
//Get the default device from the application as a first step. Discovery takes longer to complete.
BrowserPrint.getDefaultDevice("printer", function (device) {

//Add device to list of devices and to html select element
selected_device = device;
devices.push(device);
var html_select = document.getElementById("selected_device");
var option = document.createElement("option");
option.text = device.name;
html_select.add(option);

//Discover any other devices available to the application
BrowserPrint.getLocalDevices(function (device_list) {
for (var i = 0; i < device_list.length; i++) {
//Add device to list of devices and to html select element
var device = device_list[i];
if (!selected_device || device.uid != selected_device.uid) {
devices.push(device);
var option = document.createElement("option");
option.text = device.name;
option.value = device.uid;
html_select.add(option);
}
}
}, function () { alert("Error getting local devices") }, "printer");

}, function (error) {
alert(error);
})
}
function getConfig() {
BrowserPrint.getApplicationConfiguration(function (config) {
alert(JSON.stringify(config))
}, function (error) {
alert(JSON.stringify(new BrowserPrint.ApplicationConfiguration()));
})
}
function writeToSelectedPrinter(dataToWrite) {
alert("This is Express Shipment, Express Label is printing..");
selected_device.send(dataToWrite, undefined, errorCallback);
}
function window_onload() {
this.close();
}
var readCallback = function (readData) {
if (readData === undefined || readData === null || readData === "") {
alert("No Response from Device");
}
else {
alert(readData);
}

}
var errorCallback = function (errorMessage) {
alert("Error: " + errorMessage);
}

<%
Dim zpl = "^XA^FO200,200^A0N36,36^FDTest Label^FS^XZ"
Response.Write("" & vbCrLf)
Response.Write(" " & vbCrLf)
Response.Write(" try" & vbCrLf)
Response.Write(" {" & vbCrLf)
Response.Write(" setup(); " & vbCrLf)
Response.Write(" " & vbCrLf)
Response.Write(" writeToSelectedPrinter(""" & zpl & """);" & vbCrLf)
Response.Write(" }" & vbCrLf)
Response.Write(" catch(e)" & vbCrLf)
Response.Write(" {" & vbCrLf)
Response.Write(" alert(""Error in Printing "" + e);" & vbCrLf)
Response.Write(" }" & vbCrLf)
Response.Write(" " & vbCrLf)
Response.Write(" ")
%>

Please Register or Login to post a reply

2 Replies

A Alfred Teixeira

Hello,
With respect to the code above, which line(s) is/are causing the reported error?
Thank you
Al

S Steven Si

Please note that the Browser Print supports the Internet Explorer v11, Chrome and Safari. The Browser Print has not been tested against Edge. So we cannot claim that Edge is supported by the Browser Print. Please avoid using the Browser Print with Edge.

CONTACT
Can’t find what you’re looking for?