2 the ondocumentdone event, Syntax, Example – Casio Naurtech CETerm Ver.5.5 Scripting Guide User Manual
Page 84

N
AURTECH
W
EB
B
ROWSER AND
T
ERMINAL
E
MULATION FOR
W
INDOWS
CE
AND
W
INDOWS
M
OBILE
CETerm Scripting Guide
Page 84
// Return 1 if handled data here
return 1;
}
4.2
T
HE
O
N
D
OCUMENT
D
ONE
E
VENT
The OnDocumentDone event is fired when a new webpage has completed
loading into a web browser session. The handler can add META tag definitions,
examine or alter the Document Object Model (DOM), or add JavaScript methods
to the page. This event allows CETerm to enhance a web page for mobile data
collection that was not originally designed for such.
Syntax
function OnDocumentDone ( session )
session
– index of browser session which completed page load.
Example
This example shows how several META tags can be added to a web page. We
will add a “PowerOn” handler, a key remapping, and information item tags to
position the RF indicator at a special location.
The “PowerOn” handler is often
used to navigate to a specific page, such as a login page, when the device
resumes. The RF indicator tags will restore a specific location, but could be used
to alter the RF indicator location depending on the current page.
/* OnDocumentDone */
function OnDocumentDone ( session )
{
var b = CETerm.Session( session ).Browser;
// Do not process the initial about:blank page
if (!b.Document.URL.match("about:blank"))
{
// Add PowerOn META handler
b.AddMetaItem( "PowerOn",
"Javascript:alert(\"My PowerOn\");" );
// Insert new JavaScript function
b.RunScript( "function myf1() {alert(\"F1 Function\");}" );
// Add Key mapping to inserted function
b.AddMetaItem( "OnKey_F1", "Javascript:myf1();" );
// Position RF signal indicator
b.AddMetaItem( "Signal", "x=195" );