0 common tasks, 1 scanner input – Casio Naurtech CETerm Ver.5.1 Web Browser Programming Manual User Manual

Page 10

Advertising
background image

2.0 Common Tasks

This section describes some common ways that enhanced features can be used
within a Web based application. Here we show how to manage scanner input,
invoke actions via keys, and interact with the handheld device. Only small code
“snippets” are shown. For complete details see the reference sections of this
manual. These tasks help to illustrate the power of the Naurtech Web Browser
for building Web based applications.

2.1 S

CANNER

I

NPUT

The barcode scanner, and other readers such as magnetic card readers and
RFID readers are typically integrated with the Naurtech client. The configuration
of the reader is maintained by the Naurtech client and is managed to allow an
independent configuration for each host session. When data is available from a
reader, it is directed to the current host session. The data is typically inserted at
the current cursor (or focus) location. For a Web page with multiple text input
elements, this can be problematic. The focus may be in the wrong text element,
or if the focus is not in a text element, the input may be lost.

A better way to receive scanner input is to use an extension, which directs the
data to a JavaScript method or submits it to a URL. To enable this action, you
must define a special HTML META tag and a JavaScript method to process the
data. Here is a typical META tag:

<meta http-equiv="ScannerNavigate"
content="Javascript:onscan('%s','%s','%s','%s','%s');">


When the scanner reads a barcode, each of the ‘%s’ items will be filled with
information from the scan and the onscan method will be invoked. Here is a
typical method which shows what each argument contains

<script language=javascript>
function onscan(data, source, type, time, length)
{
alert("The barcode scanned was " + data +
"\nThe symbology was " + type +
"\nScanned at " + time +
"\nWith a length of " + length);
}

<\script>


This method simply presents a popup message with the scanner data. More
typically, the data would be validated and inserted into a text element. The
HTML form containing that element may also be submitted:

<script language=javascript>

Advertising