Its
interesting how many people have a need to identify the current URL from
the address bar of an open IE or Netscape session. This is by far
the simplest means ... using DDE conversation.
The results of the call to IE return two items - the site's URL as
displayed in the IE address bar, and the IE Browser's window title. Both
are returned as a single string, individually quoted and comma-delimited.
Netscape, on the other hand, always returns three pieces of information -
URL, title and frame - and the information returned differs depending on
the user's action with the site. If the site was just navigated to (no
interaction has occurred within a site's pages), the site URL and title
are returned just as with IE (the no interaction example in the
illustration), and the frame position contains an empty string. But if
interaction has taken place, the DDE conversation returns the URL of the
page upon which the interaction took place, that page's title, and the
name of the frame in which that page is located.
Thanks go out to MVP Joe LeVasseur for providing this code to the
newsgroups. |
Option Explicit
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved.
' Some pages may also contain other copyrights by the author.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Distribution: You can freely use this code in your own
' applications, but you may not reproduce
' or publish this code on any web site,
' online service, or distribute as source
' on any media without express permission.
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Option Explicit
Private Sub Command1_Click()
On Error GoTo command_error
With Label1
.Caption = ""
.AutoSize = True
.LinkTopic = "IExplore|WWW_GetWindowInfo"
.LinkItem = "0xffffffff"
.LinkMode = 2
.LinkRequest
End With
DoEvents
With Label2
.Caption = ""
.AutoSize = True
.LinkTopic = "Netscape|WWW_GetWindowInfo"
.LinkItem = "0xffffffff"
.LinkMode = 2
.LinkRequest
End With
Exit Sub
command_error:
'try the next step on error
Resume Next
End Sub |