HtmlWindow.Open 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在命名窗口中显示文件。
重载
| 名称 | 说明 |
|---|---|
| Open(String, String, String, Boolean) |
在命名窗口中显示文件。 |
| Open(Uri, String, String, Boolean) |
在命名窗口中显示文件。 |
Open(String, String, String, Boolean)
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
在命名窗口中显示文件。
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
参数
- urlString
- String
描述要加载的文件位置的统一资源定位符。
- target
- String
要在其中打开资源的窗口的名称。 这可能是开发人员提供的名称或以下特殊值之一:
_blank:在新窗口中打开 urlString 。 的工作方式与调用 OpenNew(String, String)相同。
_media:在媒体栏中打开 urlString 。
_parent:在创建当前窗口的窗口中打开 urlString 。
_search:在搜索栏中打开 urlString 。
_self:在当前窗口中打开 urlString 。
_top:如果针对属于元素的FRAME窗口调用,将在承载元素的urlString窗口中打开FRAMESET。 否则,行为与 _self.
- windowOptions
- String
一个逗号分隔的字符串,格式为 name=value以下选项的零个或多个。 除采用任意整数的 、选项和选项外,每个选项接受left或接受或topheight或width作为有效值。yes1no0
channelmode:与Internet Explorer 4.0 已弃用的通道技术一起使用。 默认值为 no。
directories:窗口是否应显示目录导航按钮。 默认值为 yes。
height:窗口工作区的高度(以像素为单位)。 最小值为 100;尝试打开小于此窗口的窗口将导致窗口根据Internet Explorer默认值打开。
left:窗口的左侧(x 坐标)位置,相对于用户屏幕左上角(以像素为单位)。 必须是正整数。
location:是否显示地址栏,使用户能够将窗口导航到新 URL。 默认值为 yes。
menubar:是否在新窗口中显示菜单。 默认值为 yes。
resizable:用户是否可以调整窗口的大小。 默认值为 yes。
scrollbars:窗口是否具有水平滚动条和垂直滚动条。 默认值为 yes。
status:窗口是否底部有状态栏。 默认值为 yes。
titlebar:是否显示当前页的标题。 将此选项设置为 no 在托管应用程序中不起作用;标题栏将始终显示。
toolbar:“ 后退”、“ 转发”和 “停止 ”等工具栏按钮是否可见。 默认值为 yes。
top:窗口的顶部(y 坐标)位置,相对于用户屏幕左上角(以像素为单位)。 必须是正整数。
width:窗口工作区的宽度(以像素为单位)。 最小值为 100;尝试打开小于此窗口的窗口将导致窗口根据Internet Explorer默认值打开。
- replaceEntry
- Boolean
true 将当前窗口的 URL 替换为 urlString 导航历史记录中的 URL。 这将影响对类的方法 HtmlHistory 的操作。
返回
新窗口或以前由参数命名的 target 窗口。
注解
该 target 参数可以命名一个窗口,该窗口是上一次调用 Open的结果。 该参数还可以通过单击超链接(A 元素)或 FORM 使用该 TARGET 属性在新窗口中打开其 URL 的元素来指向打开的窗口。 以下 HTML 代码将打开一个在用户单击它时命名 orderWindow 的新窗口:
<A HREF="/startOrder.aspx" TARGET="orderWindow">Click to Start Order</a>
如果为参数提供任何选项 windowOptions ,则不会自动禁用不包含的任何选项。 换而言之,如果仅通过 windowOptions 所需状态栏指定,则除非通过显式 windowOptions启用状态栏,否则不会显示菜单栏、工具栏、标题、滚动条等。
如果由 url 引用的文件是可在Internet Explorer内托管的 HTML 文件、文本文件或其他文件类型,则会显示在命名窗口中。 如果文件不能显示在Internet Explorer内部,并且按目标命名的窗口尚不存在,则该窗口将只打开足够长的时间,以便Internet Explorer下载资源;它随后将立即关闭。
使用 Open 或 OpenNew 创建新窗口时,它会导致 HTML 文档对象模型打开Internet Explorer的新实例。 如果未在创建的所有窗口上调用 Close,即使应用程序退出,此Internet Explorer实例也会保持运行状态。
如果使用 Open 在现有窗口中加载 URL, windowOptions 将被忽略;该窗口将保留初始调用 Open首先为其提供的尺寸、外观和屏幕位置。
适用于
Open(Uri, String, String, Boolean)
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
- Source:
- HtmlWindow.cs
在命名窗口中显示文件。
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
参数
- url
- Uri
描述要加载的文件位置的统一资源定位符。
- target
- String
要在其中打开资源的窗口的名称。 可以是开发人员提供的名称,也可以是以下特殊值之一:
_blank:在新窗口中打开 url 。 的工作方式与调用 OpenNew(String, String)相同。
_media:在媒体栏中打开 url 。
_parent:在创建当前窗口的窗口中打开 url 。
_search:在搜索栏中打开 url 。
_self:在当前窗口中打开 url 。
_top:如果针对属于元素的FRAME窗口调用,将在承载元素的url窗口中打开FRAMESET。 否则,行为与 _self.
- windowOptions
- String
一个逗号分隔的字符串,格式为 name=value以下选项的零个或多个。 除采用任意整数的 、选项和选项外,每个选项接受left或接受或topheight或width作为有效值。yes1no0
channelmode:与Internet Explorer 4.0 已弃用的通道技术一起使用。 默认值为 no。
directories:窗口是否应显示目录导航按钮。 默认值为 yes。
height:窗口工作区的高度(以像素为单位)。 最小值为 100;尝试打开小于此窗口的窗口将导致窗口根据Internet Explorer默认值打开。
left:窗口的左侧(x 坐标)位置,相对于用户屏幕左上角(以像素为单位)。 必须是正整数。
location:是否显示地址栏,使用户能够将窗口导航到新 URL。 默认值为 yes。
menubar:是否在新窗口中显示菜单。 默认值为 yes。
resizable:用户是否可以调整窗口的大小。 默认值为 yes。
scrollbars:窗口是否具有水平滚动条和垂直滚动条。 默认值为 yes。
status:窗口是否底部有状态栏。 默认值为 yes。
titlebar:是否显示当前页的标题。 将此选项设置为 no 在托管应用程序中不起作用;标题栏将始终显示。
toolbar:“ 后退”、“ 转发”和 “停止 ”等工具栏按钮是否可见。 默认值为 yes。
top:窗口的顶部(y 坐标)位置,相对于用户屏幕左上角(以像素为单位)。 必须是正整数。
width:窗口工作区的宽度(以像素为单位)。 最小值为 100;尝试打开小于此窗口的窗口将导致窗口根据Internet Explorer默认值打开。
- replaceEntry
- Boolean
true 将当前窗口的 URL 替换为 url 导航历史记录中的 URL。 这将影响类上 HtmlHistory 方法的操作。
返回
一个 HtmlWindow 表示新窗口,或以前由参数命名的 target 窗口。
示例
下面的代码示例包含两种方法:
- 第一个在一个名为
displayWindow的窗口中打开一个 URL,该 URL 在显示状态栏的情况下创建。 - 第二个 URL 在同一窗口中打开另一个 URL,但指定只应显示位置栏。
请注意,窗口的维度和显示的控件取决于首先打开的 URL。 代码示例要求窗体包含名为
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
注解
该 target 参数可以命名一个窗口,该窗口是上一次调用 Open的结果。 该参数还可以通过单击超链接(A 元素)或 FORM 使用该 TARGET 属性在新窗口中打开其 URL 的元素来指向打开的窗口。 以下 HTML 代码将打开一个在用户单击它时命名 orderWindow 的新窗口:
<A HREF="/startOrder.aspx" TARGET="orderWindow">Click to Start Order</a>
如果为参数提供任何选项 windowOptions ,则不会自动禁用不包含的任何选项。 换而言之,如果仅通过 windowOptions 所需状态栏指定,则除非通过显式 windowOptions启用状态栏,否则不会显示菜单栏、工具栏、标题、滚动条等。
如果由 url 引用的文件是可在Internet Explorer内托管的 HTML 文件、文本文件或其他文件类型,则会显示在命名窗口中。 如果文件不能显示在Internet Explorer内部,并且按目标命名的窗口尚不存在,则该窗口将只打开足够长的时间,以便Internet Explorer下载资源;它随后将立即关闭。
使用 Open 或 OpenNew 创建新窗口时,它会导致 HTML 文档对象模型打开Internet Explorer的新实例。 如果未在创建的所有窗口上调用 Close,即使应用程序退出,此Internet Explorer实例也会保持运行状态。
如果使用 Open 在现有窗口中加载 URL, windowOptions 将被忽略;该窗口将保留初始调用 Open首先为其提供的尺寸、外观和屏幕位置。