Back

CreateWebView

WebView creates a WebView control to display local or remote web pages in the app.

app.CreateWebView( width, height, options, zoom ) -> app object - WebView

Example - Remote



function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

     web = app.CreateWebView( 0.8, 0.8 );
     web.SetOnProgress( web_OnProgess );
     lay.AddChild( web );

     app.AddLayout( lay );

     app.ShowProgress("Loading...");
     web.LoadUrl( "http:///www.google.com" );
}

function web_OnProgess( progress )
{
     app.Debug( "progress = " + progress );
     if( progress==100 ) app.HideProgress();
}
    Copy     Copy All       Run      

Example - Local



function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

     web = app.CreateWebView( 0.8, 0.8 );
     web.SetBackColor( "#00000000" );
     lay.AddChild( web );

     app.AddLayout( lay );

     web.LoadUrl( "file:///Sys/Html/Page.htm" );
}
    Copy     Copy All       Run      

Example - Direct



function OnStart()
{
    lay = app.CreateLayout( "linear", "VCenter,FillXY" );

     web = app.CreateWebView( 0.8, 0.8 );
     web.SetBackColor( "#00000000" );
     lay.AddChild( web );

     app.AddLayout( lay );

     var html = "<html><head>";
     html += "<meta name='viewport' content='width=device-width'>";
     html += "</head><body>Hello World!<br>";
     html += "<img src='Img/Droid2.png'>";
     html += "</body></html>";
     web.LoadHtml( html, "file:///Sys/" );
}
    Copy     Copy All       Run      

The following methods are avaiable on the WebView object:

  Back()
  CanGoBack() -> boolean
  Capture( file )
  Destroy()
  Explode()
  Focus()
  Forward()
  GetAbsHeight() -> number - integer
  GetAbsWidth() -> number - integer
  GetHeight( options ) -> number - fraction of screen height
  GetLeft( options ) -> number - fraction of screen width
  GetPosition( options ) -> object - { left: fraction of parent width, top: fraction of parent height, right: fraction of parent width, bottom: fraction of parent height }
  GetTop( options ) -> number - fraction of screen height
  GetType() -> string - "WebView"
  GetUrl() -> string - url path
  GetVisibility() -> string - "Show" or "Hide" or "Gone"
  GetWidth( options ) -> number - fraction of screen width
  Gone()
  Hide()
  IsEnabled() -> boolean
  IsOverlap( obj, depth ) -> boolean
  IsVisible() -> boolean
  Print()
  Reload()
  SetScale( x, y )
  Show()
  id -> string - "#id"

unknown
number
set color effects
load previous page if possible
returns wether there is a previous page
returns wether there is a following page
string - path to file or folder ( "/absolute/..." or "relative/..." )
? screenshot?
?
ClearHistory for Back() and Forward()
destroys object
destroys object with explode animation and sound
?
losd next page
get height in pixels
get width in pixels
get screen relative height
get distance to left parent border
get distance to upper parent border
returns current website url
GetVisibility
get screen relative width
Set visibility "Gone"
Set visibility "Hide"
IsEnabled
app object
number - fraction of screen width
return wether obj overlap with an other
IsVisible
string - html
string - url path
LoadUrl
string
number - integer
boolean
called when console was accessed
Print current page
?
Reload current page
string -
  hexadecimal: "#rrggbb", "#aarrggbb"
  colourName: "red", "green", ...
SetBackColor
number - fraction of screen height
SetBackColorRadial
changes the background image
string - "Add" or "Multiply" or "?"
adjust color
en/disable object
move object from current position
function( error )
called when error appeared
function( ? )
?
set surrounding borders
SetPosition
?
number - factor
SetScale
change object size
?
?
string - "Show" or "Hide" or "Gone"
change visibility mode
Set visibility "Show"
?
?
object id