Scripting Guide

NAURTECH WEB BROWSER AND TERMINAL EMULATION FOR WINDOWS CE AND WINDOWS MOBILE
CETerm Scripting Guide Page 89
4.6 THE ONNAVIGATEREQUEST EVENT
The OnNavigateRequest event is fired before the browser begins a navigation.
Normally, all navigation control should be done within the HTML of a page. In
rare cases when the pages cannot be modified, this handler can be used to
control navigations. This handler can cancel a navigation or request an
alternative navigation.
Syntax
function OnNavigateRequest ( session, url )
session index of browser session.
url target URL of navigation request.
The return value of OnNavigateRequest is used to control the navigation. A
return value of 0 will allow the navigation to continue, a value greater than 0 will
cancel the navigation.
Example
This example shows how to control navigation.
/* OnNavigateRequest */
function OnNavigateRequest( session, url )
{
// Prevent unwanted URL
if (url.match( "forbidden.htm" )) return 1;
// Require password
if (url.match( "protected.htm" ))
{
var t = CETerm.TextInput;
t.Title = "Administrator Login";
t.Prompt = "Please enter your password:";
t.PasswordMode = true;
t.Input = ""; // Clear current password
var s = t.GetInput();
if (s !== 1 || t.Input !== "secret")
{
// Bad password, cancel
return 1;
}
t.Input = ""; // Clear password
}