HtmlWindow.Open 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.
Displays a file in the named window.
Overloads
Open(String, String, String, Boolean) |
Displays a file in the named window. |
Open(Uri, String, String, Boolean) |
Displays a file in the named window. |
Open(String, String, String, Boolean)
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
Displays a file in the named window.
public:
System::Windows::Forms::HtmlWindow ^ Open(System::String ^ urlString, System::String ^ target, System::String ^ windowOptions, bool replaceEntry);
public System.Windows.Forms.HtmlWindow Open (string urlString, string target, string windowOptions, bool replaceEntry);
public System.Windows.Forms.HtmlWindow? Open (string urlString, string target, string windowOptions, bool replaceEntry);
member this.Open : string * string * string * bool -> System.Windows.Forms.HtmlWindow
Public Function Open (urlString As String, target As String, windowOptions As String, replaceEntry As Boolean) As HtmlWindow
Parameters
- urlString
- String
The Uniform Resource Locator that describes the location of the file to load.
- target
- String
The name of the window in which to open the resource. This may be a developer-supplied name, or one of the following special values:
_blank
: Opens urlString
in a new window. Works the same as a call to OpenNew(String, String).
_media
: Opens urlString
in the Media bar.
_parent
: Opens urlString
in the window that created the current window.
_search
: Opens urlString
in the Search bar.
_self
: Opens urlString
in the current window.
_top
: If called against a window belonging to a FRAME
element, opens urlString
in the window hosting its FRAMESET
. Otherwise, acts the same as _self
.
- windowOptions
- String
A comma-delimited string consisting of zero or more of the following options in the form name=value
. Except for the left
, top
, height
, and width
options, which take arbitrary integers, each option accepts yes
or 1
, and no
or 0
, as valid values.
channelmode
: Used with the deprecated channels technology of Internet Explorer 4.0. Default is no
.
directories
: Whether the window should display directory navigation buttons. Default is yes
.
height
: The height of the window's client area, in pixels. The minimum is 100; attempts to open a window smaller than this will cause the window to open according to the Internet Explorer defaults.
left
: The left (x-coordinate) position of the window, relative to the upper-left corner of the user's screen, in pixels. Must be a positive integer.
location
: Whether to display the Address bar, which enables users to navigate the window to a new URL. Default is yes
.
menubar
: Whether to display menus on the new window. Default is yes
.
resizable
: Whether the window can be resized by the user. Default is yes
.
scrollbars
: Whether the window has horizontal and vertical scroll bars. Default is yes
.
status
: Whether the window has a status bar at the bottom. Default is yes
.
titlebar
: Whether the title of the current page is displayed. Setting this option to no
has no effect within a managed application; the title bar will always appear.
toolbar
: Whether toolbar buttons such as Back, Forward, and Stop are visible. Default is yes
.
top
: The top (y-coordinate) position of the window, relative to the upper-left corner of the user's screen, in pixels. Must be a positive integer.
width
: The width of the window's client area, in pixels. The minimum is 100; attempts to open a window smaller than this will cause the window to open according to the Internet Explorer defaults.
- replaceEntry
- Boolean
true
to replace the current window's URL with urlString
in the navigation history. This will effect the operation of methods on the HtmlHistory class.
Returns
The new window, or the previously created window named by the target
parameter.
Remarks
The target
parameter can name a window that was created as the result of a previous call to Open. The parameter may also point to a window opened by clicking on a hyperlink (A
element) or a FORM
element that uses the TARGET
attribute to open its URL in a new window. The following HTML code will open a new window named orderWindow
when the user clicks it:
<A HREF="/startOrder.aspx" TARGET="orderWindow">Click to Start Order</a>
If you supply any options for the windowOptions
parameter, any option not included is automatically disabled. In other words, if you only specify by way of windowOptions
that you want a status bar, then the menu bar, toolbar, title, scroll bars, and so on will not be displayed unless you explicitly enable them by way of windowOptions
.
If the file referenced by url
is an HTML file, text file, or other file type that can be hosted inside of Internet Explorer, it will be displayed in the named window. If the file cannot be displayed inside of Internet Explorer, and the window named by target does not already exist, then the window will open only long enough for Internet Explorer to download the resource; it will close immediately afterwards.
When you create new windows using Open or OpenNew, it causes the HTML Document Object Model to open a new instance of Internet Explorer. If you do not call Close on all of the windows you have created, this instance of Internet Explorer will remain running even after your application has quit.
If you use Open to load a URL in an existing window, windowOptions
will be ignored; the window will retain the dimensions, appearance, and screen location first given it by the initial call to Open.
Applies to
Open(Uri, String, String, Boolean)
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
Displays a file in the named window.
public:
System::Windows::Forms::HtmlWindow ^ Open(Uri ^ url, System::String ^ target, System::String ^ windowOptions, bool replaceEntry);
public System.Windows.Forms.HtmlWindow Open (Uri url, string target, string windowOptions, bool replaceEntry);
public System.Windows.Forms.HtmlWindow? Open (Uri url, string target, string windowOptions, bool replaceEntry);
member this.Open : Uri * string * string * bool -> System.Windows.Forms.HtmlWindow
Public Function Open (url As Uri, target As String, windowOptions As String, replaceEntry As Boolean) As HtmlWindow
Parameters
- url
- Uri
The Uniform Resource Locator that describes the location of the file to load.
- target
- String
The name of the window in which to open the resource. This can be a developer-supplied name, or one of the following special values:
_blank
: Opens url
in a new window. Works the same as a call to OpenNew(String, String).
_media
: Opens url
in the Media bar.
_parent
: Opens url
in the window that created the current window.
_search
: Opens url
in the Search bar.
_self
: Opens url
in the current window.
_top
: If called against a window belonging to a FRAME
element, opens url
in the window hosting its FRAMESET
. Otherwise, acts the same as _self
.
- windowOptions
- String
A comma-delimited string consisting of zero or more of the following options in the form name=value
. Except for the left
, top
, height
, and width
options, which take arbitrary integers, each option accepts yes
or 1
, and no
or 0
, as valid values.
channelmode
: Used with the deprecated channels technology of Internet Explorer 4.0. Default is no
.
directories
: Whether the window should display directory navigation buttons. Default is yes
.
height
: The height of the window's client area, in pixels. The minimum is 100; attempts to open a window smaller than this will cause the window to open according to the Internet Explorer defaults.
left
: The left (x-coordinate) position of the window, relative to the upper-left corner of the user's screen, in pixels. Must be a positive integer.
location
: Whether to display the Address bar, which enables users to navigate the window to a new URL. Default is yes
.
menubar
: Whether to display menus on the new window. Default is yes
.
resizable
: Whether the window can be resized by the user. Default is yes
.
scrollbars
: Whether the window has horizontal and vertical scroll bars. Default is yes
.
status
: Whether the window has a status bar at the bottom. Default is yes
.
titlebar
: Whether the title of the current page is displayed. Setting this option to no
has no effect within a managed application; the title bar will always appear.
toolbar
: Whether toolbar buttons such as Back, Forward, and Stop are visible. Default is yes
.
top
: The top (y-coordinate) position of the window, relative to the upper-left corner of the user's screen, in pixels. Must be a positive integer.
width
: The width of the window's client area, in pixels. The minimum is 100; attempts to open a window smaller than this will cause the window to open according to the Internet Explorer defaults.
- replaceEntry
- Boolean
true
to replace the current window's URL with url
in the navigation history. This will affect the operation of methods on the HtmlHistory class.
Returns
An HtmlWindow representing the new window, or the previously created window named by the target
parameter.
Examples
The following code example contains two methods:
- The first opens a URL in a window named
displayWindow
, which it creates with a status bar displayed. - The second opens another URL in the same window, but specifies that only the location bar should be displayed.
Notice that the dimensions of the window and the controls that are displayed depends on which URL is opened first. The code example requires that your form contains a WebBrowser control named WebBrowser1
.
private void DisplayFirstUrl()
{
if (webBrowser1.Document != null)
{
//If this is called first, the window will only have a status bar.
webBrowser1.Document.Window.Open(new Uri("http://www.microsoft.com/"), "displayWindow", "status=yes,width=200,height=400", false);
}
}
private void DisplaySecondUrl()
{
if (webBrowser1.Document != null)
{
// If this is called first, the window will only have an Address bar.
webBrowser1.Document.Window.Open(new Uri("http://msdn.microsoft.com/"), "displayWindow", "width=400,height=200,location=yes", false);
}
}
Private Sub DisplayFirstUrl()
If (WebBrowser1.Document IsNot Nothing) Then
With WebBrowser1.Document
' If this is called first, the window will only have a status bar.
.Window.Open(New Uri("http://www.microsoft.com/"), "displayWindow", "status=yes,width=200,height=400", False)
End With
End If
End Sub
Private Sub DisplaySecondUrl()
If (WebBrowser1.Document IsNot Nothing) Then
With WebBrowser1.Document
' If this is called first, the window will only have an Address bar.
.Window.Open(New Uri("http://msdn.microsoft.com/"), "displayWindow", "width=400,height=200,location=yes", False)
End With
End If
End Sub
Remarks
The target
parameter can name a window that was created as the result of a previous call to Open. The parameter may also point to a window opened by clicking on a hyperlink (A
element) or a FORM
element that uses the TARGET
attribute to open its URL in a new window. The following HTML code will open a new window named orderWindow
when the user clicks it:
<A HREF="/startOrder.aspx" TARGET="orderWindow">Click to Start Order</a>
If you supply any options for the windowOptions
parameter, any option not included is automatically disabled. In other words, if you only specify by way of windowOptions
that you want a status bar, then the menu bar, toolbar, title, scroll bars, and so on will not be displayed unless you explicitly enable them by way of windowOptions
.
If the file referenced by url
is an HTML file, text file, or other file type that can be hosted inside of Internet Explorer, it will be displayed in the named window. If the file cannot be displayed inside of Internet Explorer, and the window named by target does not already exist, then the window will open only long enough for Internet Explorer to download the resource; it will close immediately afterwards.
When you create new windows using Open or OpenNew, it causes the HTML Document Object Model to open a new instance of Internet Explorer. If you do not call Close on all of the windows you have created, this instance of Internet Explorer will remain running even after your application has quit.
If you use Open to load a URL in an existing window, windowOptions
will be ignored; the window will retain the dimensions, appearance, and screen location first given it by the initial call to Open.