In case anyone is interested, the following code is hacked from a WebView I used before that needed a downloadComplete function.
I have altered it to fill in a very simple form at
http://droidscript.sgarman.net/welcome.html
//Called when application is started.
function OnStart()
{
//Create a layout with objects vertically centered.
lay = app.CreateLayout( "linear", "VCenter,FillXY" );
//Create a text label and add it to layout.
var url = "
http://droidscript.sgarman.net/welcome.html"
web = createWebView( .8,.8 );
web.SetOnProgress(progress)
lay.AddChild( web );
web.Load(url,"URL");
//Add layout to app.
app.AddLayout( lay );
}
function progress(percent)
{
if(percent==100) downloadComplete(this);
}
function downloadComplete(webview)
{
if(webview.loadtype=="url")
{
//prevent looping
webview.loadtype="";
//sign in
exec(webview);
}
}
function exec(webview)
{
webview.Execute('document.forms["myform"]["name"].value="Steve the Great"');
webview.Execute('document.forms["myform"]["email"].value="st...@greatpeople.xxx"');
webview.Execute('document.forms["myform"].submit()');
}
function createWebView(width, height)
{
var w = app.CreateWebView(width,height);
w.loadtype="";
w.url="";
w.html="";
w.Load = function(data,type)
{
type = type||"url"
type = type.toLowerCase();
w.loadtype = type;
if(type == "url")
{
w.url = data;
w.LoadUrl(data);
}
if(type == "html")
{
w.html = data;
w.LoadHtml(data);
}
}
return w;
}