The IE window executing the JavaScript will be created via a new
ShDocVw.InternetExplorer.
Basically, I need to know if there is a way to listen for new windows being
created (via some event exposed via ShDocVw).
I can pretty much assume that my instance of ShDocVw.InternetExplorer will
*only* be opening a new instance via JavaScript, so any new windows spawned
from that instance can be assumed to be generated from the JavaScript
command.
Ideally, ShDocVw.InternetExplorer would expose an event that fired any time
a new window was generated from that instance of IE. The event would have an
argument containing the HWND of the new window. Alas, I don't really see any
event like this.
Any ideas?
RMD
set Wnds = CreateObject("Shell.Application")
For each oWnd in Wnds.windows
'Or do you want oWnd.hWnd?
If TypeName(oWin.document) = "HTMLDocument" Then
If oWin.document.body Is myInstanceTopLevelBody
...
End If
End If
Next
If you happen to have ahold of a DOM element within a frame,
then it's a bit stickier getting to the top level window.
Csaba Gabor from New York
"RMD" <rmd@ask_me_if_you_want_it.ok> wrote in message news:ODrWXU$KDHA...@TK2MSFTNGP09.phx.gbl...
If the oWnd in question is the popup I'm concerned with,
"oWin.document.body" will evaluate to the body property of the window that
caused the popup?
So if i do something like:
set objOriginalDoc = objIE.document;
'Do your loop...
if oWin.document.body is objOriginalDoc.body then
'.. we've found the window that was caused by the JavaScript window.open
command
Correct?
RMD
"Csaba2000" <ne...@CsabaGabor.com> wrote in message
news:ubGsYt$KDHA...@tk2msftngp13.phx.gbl...
Csaba
"RMD" <rmd@ask_me_if_you_want_it.ok> wrote in message news:#SK0iADL...@tk2msftngp13.phx.gbl...
So a popup window caused by javascript doesn't have its own document.body?
RMD
"Csaba2000" <ne...@CsabaGabor.com> wrote in message
news:%23dtO6lE...@TK2MSFTNGP09.phx.gbl...
After further investigation, I discovered the
InternetExplorer.Document.ParentWindow.Opener property.
This seemed to be exactly what I needed, but it doesn't seem to be populated
with anything for my popup window. Shouldn't it point to the instance of IE
that ran the javascript which opened it?
I even tried modifying my javascript so that it explicitly set the popup
window's opener property like:
var win = window.open(...);
win.opener = this;
But that doesn't seem to make any difference.
What am I doing wrong?
RMD
"Csaba2000" <ne...@CsabaGabor.com> wrote in message
news:%23dtO6lE...@TK2MSFTNGP09.phx.gbl...
Perhaps post a bit more of your code. "doesn't seem to work" and
"doesn't seem to make any difference" are too vague for me.
Let's see the part that's doing the creation and the part that's
doing the testing.
Csaba
"RMD" <rmd@ask_me_if_you_want_it.ok> wrote in message news:OPgT0jKL...@tk2msftngp13.phx.gbl...
Instead, I handle the NewWindow2 event from the instance of IE that's
loading the JavaScript.
When the event fires, I create a new instance of IE and save a reference to
it, then I set the ppDisp object's reference equal to the IE instance I just
created.
I can then close the popup whenever I want by just calling the Quit method
of my IE instance.
Once I launch the instance of IE that loads the JavaScript, I just have to
enter a while loop, call DoEvents, sleep for a few milliseconds, then repeat
the loop until my reference is set by the event handler. Once it is, I exit
the loop and continue on with my application.
Thanks for your help.
RMD
"Csaba2000" <ne...@CsabaGabor.com> wrote in message
news:%23Vn4iBM...@tk2msftngp13.phx.gbl...
Csaba
"RMD" <rmd@ask_me_if_you_want_it.ok> wrote in message news:#Tne7EML...@tk2msftngp13.phx.gbl...