Description
Browses the specified Web page.
Applies to
WebBrowser controls
Syntax
controlname.Navigate ( string url )
Argument |
Description |
---|---|
controlname |
The name of the WebBrowser control. |
url |
The address of the page to browse. |
Return value
Integer.
Returns values as follows. If any argument's value is null, the method returns null.
-
1 -- Success
-
-1 -- Failed to execute the line.
-
-2 -- Failed to initialize the control and obtain the WebBrowser object. The WebView2 is invalid.
-
-4 -- The target path does not exist.
-
-5 -- The URI is invalid.
-
-6 -- The specified download task does not exist.
-
-8 -- The setting item does not exist.
-
-9 -- The path is invalid or does not exist.
-
-11 -- Unknown error.
-
-12 -- Invalid event name.
-
-14 -- Invalid argument.
-
-15 -- Failed to create screenshot file.
-
-16 -- There is a print job in progress, which cannot be closed.
-
-17 -- Could not find the corresponding item.
Usage
The Navigate function is executed asynchronously. Therefore, if the next script must be executed after the Navigate function is completed, then it is recommended to check the value of the NavigationProgressIndex event, and only after the event receives the value of 100 (which means the page is 100% loaded), the next script should be executed. For example,
String ls_temp ls_temp = "D:/PB/PB2019R3/WebBrowser/JavaScript/ManuTestCase/html/JavaScript_011.html" wb_1.navigate( 'file:///' + ls_temp ) ib_init = false //Instance Variables: Boolean ib_init
If Not ib_init Then If progressindex = 100 Then ib_init = true print() End If End If
But if the page to be loaded is complicated (such as loading multiple frames, embedding large amount of data, associating and accessing data from other websites, having complex logics or deep hierarchical structure etc.), the value of 100 may not indicate that the page is completely loaded. In such case, you can consider using Yield and Sleep functions to delay executing the next script. For example,
wb_1.navigate( 'file:///' + ls_temp ) yield() sleep(2) print()
Examples
This example navigates to the Appeon website:
Integer li_rtn li_rtn = wb_1.Navigate("http://www.appeon.com")
See also