This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
built_in:webview [2015/01/07 09:54] octazid [Methods] |
built_in:webview [2018/08/16 08:46] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== WebView control ====== | ====== WebView control ====== | ||
- | ===== Create | + | |
- | You can create a control to display local or remote web pages in your App using the CreateWebView method of the app object: | + | // |
+ | |||
+ | ===== Description | ||
+ | You can create a control to display local or remote web pages in your App using the **CreateWebView** method of the **[[built_in: | ||
< | < | ||
- | If you are loading remote web pages, then you might want to use the SetOnProgress method to set the name of a callback function that you want called to report the progress of loading the page. | + | options include **" |
- | You can use the LoadUrl | + | If you are loading remote web pages, then you might want to use the **SetOnProgress** |
+ | You can use the **LoadUrl** method to load an internal or external web page or the **LoadHtml** method to load text directly from within your App. | ||
< | < | ||
< | < | ||
Note: Using a WebView can be a good way of displaying colored and formatted text areas in your App. If you set the BackColor to a transparent color you can show formatted text over a background image. | Note: Using a WebView can be a good way of displaying colored and formatted text areas in your App. If you set the BackColor to a transparent color you can show formatted text over a background image. | ||
- | If you need to, you can use the Execute method to execute JavaScript code within the WebView. | + | If you need to, you can use the **Execute** method to execute JavaScript code within the WebView. |
< | < | ||
+ | |||
+ | |||
===== Methods ===== | ===== Methods ===== | ||
Some controls use the same methods.\\ | Some controls use the same methods.\\ | ||
For examples of the **[[same methods]]** look here. | For examples of the **[[same methods]]** look here. | ||
^Method ^Description ^ | ^Method ^Description ^ | ||
- | |WebView.Back() | | | + | |[[tips_tricks: |
- | |WebView.CanGoBack() | | | + | |[[tips_tricks: |
|WebView.CanGoForward() | | | |WebView.CanGoForward() | | | ||
- | |WebView.Destroy() | | | + | |WebView.Capture(filename) |captures jpeg of visible page | |
+ | |WebView.ClearHistory() | | | ||
|WebView.Execute( code ) | | | |WebView.Execute( code ) | | | ||
|WebView.Forward() | | | |WebView.Forward() | | | ||
Line 29: | Line 35: | ||
|WebView.GetPosition() | | | |WebView.GetPosition() | | | ||
|WebView.GetType() | | | |WebView.GetType() | | | ||
+ | |WebView.GetUrl() | returns the current url| | ||
|WebView.GetVisibility() | | | |WebView.GetVisibility() | | | ||
|WebView.GetWidth() | | | |WebView.GetWidth() | | | ||
|WebView.LoadHtml( html, | |WebView.LoadHtml( html, | ||
|WebView.LoadUrl( url,options ) | | | |WebView.LoadUrl( url,options ) | | | ||
- | |WebView.Release() | | | + | |WebView.Print() |KitKat or later only | |
- | |WebView.SetBackColor( | + | |WebView.SetBackColor( |
- | |WebView.SetBackGradient( | + | |WebView.SetBackGradient( |
- | |WebView.SetBackGradientRadial( | + | |WebView.SetBackGradientRadial( |
- | |WebView.SetBackground( | + | |WebView.SetBackground( |
|WebView.SetMargins( left, | |WebView.SetMargins( left, | ||
|WebView.SetOnProgress( callback ) | | | |WebView.SetOnProgress( callback ) | | | ||
- | |WebView.SetPadding( | + | |WebView.SetPadding( |
- | |WebView.SetPosition( | + | |WebView.SetPosition( |
|WebView.SetScale( x,y ) | | | |WebView.SetScale( x,y ) | | | ||
- | |WebView.SetSize( | + | |WebView.SetSize( |
|WebView.SetVisibility( HideShow ) | | | |WebView.SetVisibility( HideShow ) | | | ||
+ | |||
+ | ===== Example - Remote ===== | ||
+ | <code javascript> | ||
+ | function OnStart() | ||
+ | { | ||
+ | lay = app.CreateLayout( " | ||
+ | |||
+ | web = app.CreateWebView( 0.8, 0.8 ); | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | | ||
+ | } | ||
+ | |||
+ | function web_OnProgess( progress ) | ||
+ | { | ||
+ | | ||
+ | if( progress==100 ) app.HideProgress(); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Example - Local ===== | ||
+ | <code javascript> | ||
+ | function OnStart() | ||
+ | { | ||
+ | lay = app.CreateLayout( " | ||
+ | |||
+ | web = app.CreateWebView( 0.8, 0.8 ); | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== Example - Direct ===== | ||
+ | <code javascript> | ||
+ | function OnStart() | ||
+ | { | ||
+ | lay = app.CreateLayout( " | ||
+ | |||
+ | web = app.CreateWebView( 0.8, 0.8 ); | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | var html = "< | ||
+ | html += "< | ||
+ | html += "</ | ||
+ | html += "< | ||
+ | html += "</ | ||
+ | | ||
+ | } | ||
+ | </ |