Class

WebLocation


Description

The device location provided by the browser.

Properties

Name

Type

Read-Only

Shared

ControlID

String

Enabled

Boolean

Name

String

Page

WebPage

PanelIndex

Integer

Parent

WebView

Methods

Name

Parameters

Returns

Shared

Close

ExecuteJavaScript

Script As String

GoToURL

Url As String, inNewWindow As Boolean = False

Request

highAccuracy As Boolean

Start

highAccuracy As Boolean

Stop

UpdateBrowser

Events

Name

Parameters

Returns

Closed

Error

error As RuntimeException

LocationChanged

latitude As Double, longitude As Double, accuracy As Double, altitude As Double, altitudeAccuracy As Double, course As Double, speed As Double

Opening

Property descriptions


WebLocation.ControlID

ControlID As String

Identifies the control on a per session basis.

This property is read-only.


WebLocation.Enabled

Enabled As Boolean

When True the WebControl is drawn enabled and responds to user action. When False, the control appears as disabled and does not respond to user actions.

In the case of WebTimer, when set to False this disables and stops the WebTimer. When set to True, it starts the WebTimer.

Disable a button when a check box value changes:

If AllowSaveCheckBox.Value Then
  SaveButton.Enabled = True
Else
  AllowSaveButton.Enabled = False
End If

WebLocation.Name

Name As String

The name of the control.

This property is read-only.


WebLocation.Page

Page As WebPage

Identifies the web page that contains the control.

This property is read-only.


WebLocation.PanelIndex

PanelIndex As Integer

If the control has been placed on a WebTabPanel or WebPagePanel control, this is the panel (page/tab) that the control is on. If the control is not on a panel, it returns -1.

The first panel is numbered zero. If the control has been placed on a panel of a WebTabPanel or WebPagePanel control, it returns the panel number. If the control is not on a WebPagePanel or WebTabPanel, it returns -1. If you change the PanelIndex to a nonexistent panel, the control will disappear until you give it a PanelIndex value that corresponds to a panel that exists.

If you are looking to change the currently selected panel (page/tab), use SelectedPanelIndex.

This code displays the panel index of the control that is on the page.

MessageBox(Me.SelectedPanelIndex.ToString)

WebLocation.Parent

Parent As WebView

Used to get the control's parent control or page. If the parent control is a WebContainer, then it returns the WebContainer. If it is on a WebPage, it returns the WebPage.

This property is read-only.

Method descriptions


WebLocation.Close

Close

Removes the control from the page.


WebLocation.ExecuteJavaScript

ExecuteJavaScript(Script As String)

Executes the JavaScript passed. The JavaScript passed can call a JavaScript function in a WebPageSource control.

The Xojo web framework uses EcmaScript 6 which is more strict than previous versions of JavaScript. For more details, see the EcmaScript 6 documentation.

This code in the Pressed event of a Button displays an alert using JavaScript:

Me.ExecuteJavaScript("alert('Hello!');")

This code will select the text in a WebTextField (or WebTextArea):

WebTextField1.ExecuteJavascript("document.getElementById('" + _
  WebTextField1.ControlID + "_inner').select();")

WebLocation.GoToURL

GoToURL(Url As String, inNewWindow As Boolean = False)

Opens the passed URL in place of the current web page or downloads a file. If InNewWindow is True, the browser is asked to open the URL in a new window.

If the browser has popup windows disabled and InNewWindow is True, the method silently fails and the page is not shown.

If InNewWindow is False, the running web app is replaced with the specified URL. If you want to display an external web site within your web app, use the WebHTMLViewer control.

Display a web site in a new popup window:

Me.GoToURL("http://www.wikipedia.org", True)

WebLocation.Request

Request(highAccuracy As Boolean)

Requests the user's location a single time. Setting highAccuracy to True uses more power on mobile devices.


WebLocation.Start

Start(highAccuracy As Boolean)

Starts monitoring the user's location. Setting highAccuracy to True uses more power on mobile devices.

Only start monitoring the device location when you really need the information especially on mobile devices as monitoring uses a lot of power.


WebLocation.Stop

Stop

Stops monitoring the user's location.

Call this method as soon as you no longer need to monitor the device location especially on mobile devices as monitoring uses a lot of power.


WebLocation.UpdateBrowser

UpdateBrowser

Forces the current values of the control to be sent to the browser.

This method is useful when you are computing values in a loop and wish to update the browser immediately rather than wait until the current method ends.

This code iterates through a RowSet of database rows, updates a ProgressBar and then forces the updated ProgressBar to be sent to the browser via UpdateBrowser.

ProgressBar1.MaximumValue = SalesData.RowCount
For Each row As DatabaseRow in SalesData
 AnalyzeSales(row)
 ProgressBar1.Value = ProgressBar1.Value + 1
 ProgressBar1.UpdateBrowser
Next

Event descriptions


WebLocation.Closed

Closed

The control has been removed from the browser either because the page has closed or the control's Close method was called.


WebLocation.Error

Error(error As RuntimeException)

Called when an error occurs when calling the Start or Request methods.

This event will be called if the browser does not support geolocation or you attempt to use it over a regular HTTP connection.


WebLocation.LocationChanged

LocationChanged(latitude As Double, longitude As Double, accuracy As Double, altitude As Double, altitudeAccuracy As Double, course As Double, speed As Double)

Called when the device location information is received from the browser.


WebLocation.Opening

Opening

The control has been created and the page is opening but has not been sent to the browser yet.

The Opening event handler can be used to initialize non-visual properties and settings for controls.

In most cases, you should use the Shown event to initialize controls.

Notes

WebLocation works only over HTTPS connections.

Compatibility

Web projects on all supported operating systems.

See also

WebControl parent class.