|
|
|
date: Sat, 10 Mar 2007 10:46:08 -0800,
group: microsoft.public.inetsdk.programming.webbrowser_ctl
back
Re: WebBrowser Control and IFrame elements
That was very helpful, but for a later stage in this development. It is nice
gaining the knowledge of how to direct the new window to an
application-created window, however, the creation of the new window is
initiated by clicking an image that is contained withing a Frame (IFRAME
tags). The image, <IMG>, is contained within <A> tags which are contained
within the aforementioned <IFRAME> tags. Using the GetElementsBY... methods
of the Document object does not return any of the objects within the IFrame
section, therefore, I dont have access to the Click method of the link or
image object that brings this new window about.
I guess my initial question should have been, how do I gain access to the
document elements within an IFrame?
As it is right now, I have to manually click the image to create the new
window. That manual interaction is the very thing I am trying to automate.
Thanks
"Igor Tandetnik" wrote:
> "JonWayn" wrote in message
> news:3DEB69D9-79F1-436C-ADF9-F92EBC46B717@microsoft.com
> > However, the ensuing page has an image which
> > links to data displayed in a pop-up window. This is where I run into
> > a jam. How do I reference the document object contained in that
> > pop-up window?
>
> See KB article KB184876 "How To Use the WebBrowser Control NewWindow2
> Event"
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>
date: Sun, 11 Mar 2007 07:54:03 -0700
author: JonWayn
Re: WebBrowser Control and IFrame elements
From what I've read, you can use the Navigate method and the NewWindow2 event
of the WB control to determine the output window of a page that is about to
be displayed - that is; when you know beforehand, the URL of the page to be
displayed. However, the situation I am faced with is one in which I dont know
the URL. Clicking an image, on the other hand, does not trigger the
NewWindow2 event (unless there is a way unbeknownst to me to get it to), and
therefore doesnt permit me to direct the output to a choice window.
The Click event of the IMG runs a JavaScript, passing some arguments in,
which opens a new IE window that displays the data I want to tap into. I know
this because during my work, I open another IE instance where I navigate to
the webpage that I am working with, as I go along, and experiment with a
very useful IE add-in that displays the HTML behind any element that I click.
So here is where I'm at right now. I am now able to read the contents of the
IFrame block, navigating my WB control to the url returned by the IFrame's
WindowContent.Location property - thanks to the first link you posted.
However, this page has only header information to the details I really want.
To get these details, I must click on an IMG, which runs a script that opens
an external IE window - displaying the details.
Is there any way to direct the output of the details to a choice window?
"Igor Tandetnik" wrote:
> "JonWayn" wrote in message
> news:03945B64-ADDE-4547-999F-2F23919CADEB@microsoft.com
> > I am trying to search for the text that you replied with, but I am
> > not coming up with a match. Where do I start?
>
> You must be kidding. On the off chance you are not, see
>
> http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/frames.asp
>
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>
date: Mon, 12 Mar 2007 01:08:13 -0700
author: JonWayn
Re: WebBrowser Control and IFrame elements
"JonWayn" wrote in message
news:3355C637-A9AE-44F1-8A73-FD20452E4FEC@microsoft.com
> From what I've read, you can use the Navigate method and the
> NewWindow2 event of the WB control to determine the output window of
> a page that is about to be displayed - that is; when you know
> beforehand, the URL of the page to be displayed.
To call Navigate, you of course need to know the URL you want to
navigate to.
Your statement about NewWindow2 event doesn't make sense to me. You
register a handler for this event, and the browser calls it whenever it
tries to open a new window, for whatever reason. You don't need to know
the eventual URL of that new window at the time you register the
handler, if that's what you are thinking.
> However, the
> situation I am faced with is one in which I dont know the URL.
> Clicking an image, on the other hand, does not trigger the NewWindow2
> event
It should, if a click on an image results in the browser opening a new
window. Which, you seemed to mention, does happen in your case.
> The Click event of the IMG runs a JavaScript, passing some arguments
> in, which opens a new IE window
At which point you should get NewWindow2 event.
> So here is where I'm at right now. I am now able to read the contents
> of the IFrame block, navigating my WB control to the url returned by
> the IFrame's WindowContent.Location property
Why do you do that? Why not just work with the content that's already
loaded into an iframe? Realize that window.frames collection is a
collection of window objects, one for each frame. Such objects have all
the properties and methods that a top-level window object has. For
example, if you have a page with an iframe, and that iframe has a button
with an id="mybutton", you can click it like this:
window.frames(0).mybutton.click();
> Is there any way to direct the output of the details to a choice
> window?
Yes - you handle NewWindow2 event.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
date: Mon, 12 Mar 2007 08:17:34 -0400
author: Igor Tandetnik
Re: WebBrowser Control and IFrame elements
I didnt get what I was looking for with that link. As it is right now, using
the first link you posted, I am able to access the contents of the IFrame
section of the main document - by passing the ContentWindow.Location property
of the IFrame and 1 to the Navigate method of the WB control. However, the
data contained directly within the IFrame are only header information; the
data that I really want, come up after I click an IMG element in this header.
The IMG's Click method, however, does not trigger the NewWindow2 event, which
I would need in order to direct the ensuing page to a window of choice. So, I
am still unable to tap into the details that I wish to. The IMG's click event
runs a javascript function which accepts some arguments to return the page
needed. I know this because I open another IE instance and parallel the
navigation that I do in my work as I go along using an add-in that shows the
underlying HTML of any element I click in the browser.
So, the help I need now is in figuring out a way to trap the output page
into a window I choose, following the Click event of the IMG. Or if there is
a way to run the JavaScript from the client and direct its output to my
window.
Thank you
"Igor Tandetnik" wrote:
> "JonWayn" wrote in message
> news:03945B64-ADDE-4547-999F-2F23919CADEB@microsoft.com
> > I am trying to search for the text that you replied with, but I am
> > not coming up with a match. Where do I start?
>
> You must be kidding. On the off chance you are not, see
>
> http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/frames.asp
>
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>
date: Mon, 12 Mar 2007 05:54:03 -0700
author: JonWayn
Re: WebBrowser Control and IFrame elements
disregard my last post. It was a repost of the previous post - because MS
complained that it did not go thru the first time
"JonWayn" wrote:
> I didnt get what I was looking for with that link. As it is right now, using
> the first link you posted, I am able to access the contents of the IFrame
> section of the main document - by passing the ContentWindow.Location property
> of the IFrame and 1 to the Navigate method of the WB control. However, the
> data contained directly within the IFrame are only header information; the
> data that I really want, come up after I click an IMG element in this header.
> The IMG's Click method, however, does not trigger the NewWindow2 event, which
> I would need in order to direct the ensuing page to a window of choice. So, I
> am still unable to tap into the details that I wish to. The IMG's click event
> runs a javascript function which accepts some arguments to return the page
> needed. I know this because I open another IE instance and parallel the
> navigation that I do in my work as I go along using an add-in that shows the
> underlying HTML of any element I click in the browser.
>
> So, the help I need now is in figuring out a way to trap the output page
> into a window I choose, following the Click event of the IMG. Or if there is
> a way to run the JavaScript from the client and direct its output to my
> window.
>
> Thank you
>
> "Igor Tandetnik" wrote:
>
> > "JonWayn" wrote in message
> > news:03945B64-ADDE-4547-999F-2F23919CADEB@microsoft.com
> > > I am trying to search for the text that you replied with, but I am
> > > not coming up with a match. Where do I start?
> >
> > You must be kidding. On the off chance you are not, see
> >
> > http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/frames.asp
> >
> > --
> > With best wishes,
> > Igor Tandetnik
> >
> > With sufficient thrust, pigs fly just fine. However, this is not
> > necessarily a good idea. It is hard to be sure where they are going to
> > land, and it could be dangerous sitting under them as they fly
> > overhead. -- RFC 1925
> >
> >
> >
date: Mon, 12 Mar 2007 20:45:00 -0700
author: JonWayn
Re: WebBrowser Control and IFrame elements
> Your statement about NewWindow2 event doesn't make sense to me. You
> register a handler for this event, and the browser calls it whenever it
> tries to open a new window, for whatever reason. You don't need to know
> the eventual URL of that new window at the time you register the
> handler, if that's what you are thinking.
Well, you turn out to be right. Something must have gone wrong before
though, because, I executed the Click method numerous times b4, with a break
mark at the declaration of the NewWindow2 event, and it didnt execute. Now it
does. Thanks.
> > So here is where I'm at right now. I am now able to read the contents
> > of the IFrame block, navigating my WB control to the url returned by
> > the IFrame's WindowContent.Location property
> Why do you do that? Why not just work with the content that's already
> loaded into an iframe? Realize that window.frames collection is a
> collection of window objects, one for each frame. Such objects have all
> the properties and methods that a top-level window object has. For
> example, if you have a page with an iframe, and that iframe has a button
> with an id="mybutton", you can click it like this:
>
> window.frames(0).mybutton.click();
>
Because I was referencing the IFrame by,
Doc.GetElementsByTagName("IFrame").Item(0), which did retur an object - whose
Length property returned 0; needless to say its All, and GetElementsBy...
properties returned Nothing.
I havent yet, but I'll try what you suggest in this post. I hope you are
right about the use of window.Frames ... The reason I say that is because the
last webpage you directed me to says something about Window objects not
giving access to the Frames/IFrames they contain.
Thanks a million
date: Mon, 12 Mar 2007 22:03:02 -0700
author: JonWayn
Re: WebBrowser Control and IFrame elements
This thing is frustrating me now. 2 posts ago I said that the Click method
triggers the NewWindow2 event. Well, it did 2 or so times. Now its back to
not firing that event. Are there any known problems with NewWindow2 not
firing in response to windows opened by Javascript code? Also, any
workarounds? What if I were to use the class module approach that traps IE
events, would that answer the issue?
Thanks
"Igor Tandetnik" wrote:
> "JonWayn" wrote in message
> news:4EB7EBEB-8AC2-4796-9F43-9DEF0DEBEA6A@microsoft.com
> > Because I was referencing the IFrame by,
> > Doc.GetElementsByTagName("IFrame").Item(0)
>
> From here, you can get the frame's window object with contentWindow
> property.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>
date: Tue, 13 Mar 2007 06:16:15 -0700
author: JonWayn
Re: WebBrowser Control and IFrame elements
I step thru or run my code with a break at the NewWindow2 event. I execute
imgDetailsLink.Click. Execution moves to the next line in that procedure and
a new IE window pops up. However, if I were to stop vb, switch to the
application window and manually mouse-click the image control withing the WB,
than the NewWindow2 event fires. I really dont get it
"Igor Tandetnik" wrote:
> "JonWayn" wrote in message
> news:4EB7EBEB-8AC2-4796-9F43-9DEF0DEBEA6A@microsoft.com
> > Because I was referencing the IFrame by,
> > Doc.GetElementsByTagName("IFrame").Item(0)
>
> From here, you can get the frame's window object with contentWindow
> property.
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
>
date: Tue, 13 Mar 2007 06:22:10 -0700
author: JonWayn
Re: WebBrowser Control and IFrame elements
By the way, window objects dont have an All property - unless I am
misunderstanding you when you use the term "window". If you are talking
about the object returned from WebBrowserControl.Document.Frames, then there
is no All property to it. If you were referring to something else, please
explain how I get it, its hierarchy up to its parent.
Thanks
"Igor Tandetnik" wrote in message
news:OzP1rPaZHHA.3272@TK2MSFTNGP03.phx.gbl...
> JonWayn wrote:
>> I've got a question fr you Igor: once I have a reference to the
>> contentWindow property of a frame, how do I call the methods of
>> objects contained therein without knowing their names or Ids?
>
> What _do_ you know about them? How do you plan to decide which object you
> want to work with?
>
>> Is there a way to iterate thru the elements of such window and return
>> their attributes?
>
> window.all
> --
> With best wishes,
> Igor Tandetnik
>
> With sufficient thrust, pigs fly just fine. However, this is not
> necessarily a good idea. It is hard to be sure where they are going to
> land, and it could be dangerous sitting under them as they fly
> overhead. -- RFC 1925
>
>
date: Tue, 13 Mar 2007 22:29:00 -0500
author: JonWayn
|
|