WebBrowser.Navigate Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Navigate asynchronously to the document at the specified Uri.
Overloads
Navigate(String, String, Byte[], String) |
Navigates asynchronously to the document at the specified URL and specify the target frame to load the document's content into. Additional HTTP POST data and HTTP headers can be sent to the server as part of the navigation request. |
Navigate(Uri, String, Byte[], String) |
Navigate asynchronously to the document at the specified Uri and specify the target frame to load the document's content into. Additional HTTP POST data and HTTP headers can be sent to the server as part of the navigation request. |
Navigate(String) |
Navigates asynchronously to the document at the specified URL. |
Navigate(Uri) |
Navigate asynchronously to the document at the specified Uri. |
Navigate(String, String, Byte[], String)
Navigates asynchronously to the document at the specified URL and specify the target frame to load the document's content into. Additional HTTP POST data and HTTP headers can be sent to the server as part of the navigation request.
public:
void Navigate(System::String ^ source, System::String ^ targetFrameName, cli::array <System::Byte> ^ postData, System::String ^ additionalHeaders);
public void Navigate (string source, string targetFrameName, byte[] postData, string additionalHeaders);
member this.Navigate : string * string * byte[] * string -> unit
Public Sub Navigate (source As String, targetFrameName As String, postData As Byte(), additionalHeaders As String)
Parameters
- source
- String
The URL to navigate to.
- targetFrameName
- String
The name of the frame to display the document's content in.
- postData
- Byte[]
HTTP POST data to send to the server when the source is requested.
- additionalHeaders
- String
HTTP headers to send to the server when the source is requested.
Remarks
Use the Navigate(String, String, Byte[], String) method to navigate to a URL that may include escape characters. Use the Navigate(Uri, String, Byte[], String) method to navigate to a Uri that does not include escape characters.
Applies to
Navigate(Uri, String, Byte[], String)
Navigate asynchronously to the document at the specified Uri and specify the target frame to load the document's content into. Additional HTTP POST data and HTTP headers can be sent to the server as part of the navigation request.
public:
void Navigate(Uri ^ source, System::String ^ targetFrameName, cli::array <System::Byte> ^ postData, System::String ^ additionalHeaders);
public void Navigate (Uri source, string targetFrameName, byte[] postData, string additionalHeaders);
member this.Navigate : Uri * string * byte[] * string -> unit
Public Sub Navigate (source As Uri, targetFrameName As String, postData As Byte(), additionalHeaders As String)
Parameters
- targetFrameName
- String
The name of the frame to display the document's content in.
- postData
- Byte[]
HTTP POST data to send to the server when the source is requested.
- additionalHeaders
- String
HTTP headers to send to the server when the source is requested.
Exceptions
The WebBrowser instance is no longer valid.
A reference to the underlying native WebBrowser
could not be retrieved.
Navigation from an application that is running in partial trust:
To a Uri that is not located at the site of origin, or
targetFrameName
name is notnull
or empty.
Examples
The following example shows how to navigate to a document and open it in a new browser window by specifying the "about:blank" target.
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox x:Name="addressTextBox" Width="200" />
<Button Click="goNavigateButton_Click">Go</Button>
</StackPanel>
<WebBrowser x:Name="myWebBrowser" />
</StackPanel>
private void goNavigateButton_Click(object sender, RoutedEventArgs e)
{
// Get URI to navigate to
Uri uri = new Uri(this.addressTextBox.Text, UriKind.RelativeOrAbsolute);
// Only absolute URIs can be navigated to
if (!uri.IsAbsoluteUri)
{
MessageBox.Show("The Address URI must be absolute. For example, 'http://www.microsoft.com'");
return;
}
// Navigate to the desired URL by calling the .Navigate method
this.myWebBrowser.Navigate(uri, "_blank", null, null);
}
Remarks
Use the Navigate(String, String, Byte[], String) method to navigate to a URL that may include escape characters. Use the Navigate(Uri, String, Byte[], String) method to navigate to a Uri that does not include escape characters.
Applies to
Navigate(String)
Navigates asynchronously to the document at the specified URL.
public:
void Navigate(System::String ^ source);
public void Navigate (string source);
member this.Navigate : string -> unit
Public Sub Navigate (source As String)
Parameters
- source
- String
The URL to navigate to.
Remarks
Use the Navigate(String) method to navigate to a URL that may include escape characters. Use the Navigate(Uri) method to navigate to a Uri that does not include escape characters.
Applies to
Navigate(Uri)
Navigate asynchronously to the document at the specified Uri.
public:
void Navigate(Uri ^ source);
public void Navigate (Uri source);
member this.Navigate : Uri -> unit
Public Sub Navigate (source As Uri)
Parameters
Exceptions
The WebBrowser instance is no longer valid.
A reference to the underlying native WebBrowser
could not be retrieved.
Navigation from an application that is running in partial trust to a Uri that is not located at the site of origin.
Examples
The following example shows how to use WebBrowser to navigate to a document by using the Navigate(Uri) method.
<StackPanel>
<StackPanel Orientation="Horizontal">
<TextBox x:Name="addressTextBox" Width="200" />
<Button Click="goNavigateButton_Click">Go</Button>
</StackPanel>
<WebBrowser x:Name="myWebBrowser" />
</StackPanel>
private void goNavigateButton_Click(object sender, RoutedEventArgs e)
{
// Get URI to navigate to
Uri uri = new Uri(this.addressTextBox.Text, UriKind.RelativeOrAbsolute);
// Only absolute URIs can be navigated to
if (!uri.IsAbsoluteUri)
{
MessageBox.Show("The Address URI must be absolute. For example, 'http://www.microsoft.com'");
return;
}
// Navigate to the desired URL by calling the .Navigate method
this.myWebBrowser.Navigate(uri);
}
Remarks
Calling Navigate(Uri) has the same effect as setting the Source property. Source is used from markup by developers who want to declaratively specify the initial document that WebBrowser navigates to when WebBrowser is initialized.
Use the Navigate(String) method to navigate to a URL that may include escape characters. Use the Navigate(Uri) method to navigate to a Uri that does not include escape characters.
Applies to
.NET