Archive of UserLand's first discussion group, started October 5, 1998.

Re: Getting the URL of the Front IE Window w/ VBScript

Author:Sten Linnarsson
Posted:12/20/1998; 1:48:34 PM
Topic:Getting the URL of the Front IE Window w/ VBScript
Msg #:1517 (In response to 1457)
Prev/Next:1516 / 1518

I've done quite a lot of research into this area. There is *no* way to get the URL of the active IE window from inside another web page (assuming that's where you're running your VBScript). That's intentional, otherwise a web page could snoop on your web behaviour.

From an ActiveX control or another application, yes it's possible - either through COM or through DDE. I've been using DDE. There's no documentation, but it works the same as Netscape, except the application name must be "Iexplore". That works with Opera too, by the way. See Netscape DevEdge Online for docs. In VisualBasic, you can simply create a label (call it e.g. urlInExplorer), then do

urlInExplorer.LinkTopic = "Iexplore|www_GetWindowInfo" urlInExplorer.LinkItem = "0xFFFFFFFF" urlInExplorer.LinkMode = vbLinkManual urlInExplorer.LinkRequest

You'll get urlInExplorer.Caption set to "URL","window title" (including quotes), so you'll have to extract the URL from the string yourself. The exact same code works in IE, Netscape and Opera (which responds to both "Iexplore" and "Netscape" DDE requests, not to "Opera").

Hope this helps.

I haven't used COM GetObject(...) from VB. If you get that to work, I'd be interested in hearing how you did it. Of course, if you get it to work from VBScript, I'd be *very* interested...

/Sten


There are responses to this message:


This page was archived on 6/13/2001; 4:46:48 PM.

© Copyright 1998-2001 UserLand Software, Inc.