IE Com Object, Difference between methods .Navigat

2020-02-12 13:07发布

What is the difference between $ie.Navigate("URL") and $ie.Navigate2("URL")?

Get-Member says:

Navigate       Method    void Navigate (string, Variant, Variant, Variant, Variant)  
Navigate2      Method    void Navigate2 (Variant, Variant, Variant, Variant, Variant)

Sample Code:

$ie = New-Object -ComObject InternetExplorer.Application
$ie.visible = $true

$ie.Navigate("www.stackoverflow.com")
#or
$ie.Navigate2("www.stackoverflow.com")

1条回答
ゆ 、 Hurt°
2楼-- · 2020-02-12 13:40

The difference is in the first argument URL. Here is what MSDN says:

Navigate Method

URL: A String expression that evaluates to the URL, full path, or Universal Naming Convention (UNC) location and name of the resource to display.

Navigate2 Method

URL: A variable or expression that evaluates to the URL of the resource to display, the full path to the file location, or a PIDL that represents a folder in the Shell namespace.

...

This method extends the Navigate method to allow for Shell integration; however, this method does not make Navigate obsolete. The original method can still be used for URL navigations.

查看更多
登录 后发表回答