User manual - Scripting_Guide

NAURTECH SMART CLIENTS FOR WINDOWS CE AND POCKET PC
CETerm Scripting Guide Page 42
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" );
b.AddMetaItem( "Signal", "y=100" );
// Update information items for location to take effect
CETerm.PostIDA( "IDA_INFO_REFRESH", session );
}
}
4.3 THE ONNAVIGATEERROR EVENT
The OnNavigateError event is fired if the browser fails to complete a web
navigation. Typically, the error handler will redirect the web browser to a “file:”
URL on the device for error recovery. This event may fire if the device loses RF
coverage during a navigation or the web server crashes. It is a good practice to
use the CETerm “Check Network Before Send” feature to validate RF coverage
prior to submitting the navigation request and use the OnNavigateError for
additional error handling.
Syntax
function OnNavigateError( session, params )