Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Possible to clone browser control?
Possible to clone browser control? [message #668267] Wed, 04 May 2011 18:14 Go to next message
Gary is currently offline GaryFriend
Messages: 3
Registered: May 2011
Junior Member
Context: We are using the SWT Browser control to programatically navigate web sites. When a given page has a list of links, we click one, listen for the BeforeNavigate event, abort the current navigation, create a new Browser control, and then navigate by setting the URL in the new Browser control. This leaves the page with the original list of links intact so we can click the next link and repeat the process.

This works fine for many sites, but doesn't work well in certain cases (e.g. when link doesn't generate HTTP request because it is internal javascript).

Question: Is it possible to somehow clone an existing Browser control instead of creating a new one? The cloned Browser would need to contain not only the existing page content, but also any registered DOM event handlers (e.g. javascript) and possibly any other dynamic state created by the browser.

Thanks,
Gary
Re: Possible to clone browser control? [message #668382 is a reply to message #668267] Thu, 05 May 2011 13:29 Go to previous messageGo to next message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Hi Gary,

I can't think of a way that this would be done. With Browser.evaluate()
it's possible to execute some javascript that can query for specific aspects
of the current page's state, but there isn't a generic way to just create a
clone of the whole thing.

Grant


"Gary" <ghirschhorn@fetch.com> wrote in message
news:ips4i3$b80$1@news.eclipse.org...
> Context: We are using the SWT Browser control to programatically navigate
> web sites. When a given page has a list of links, we click one, listen
> for the BeforeNavigate event, abort the current navigation, create a new
> Browser control, and then navigate by setting the URL in the new Browser
> control. This leaves the page with the original list of links intact so we
> can click the next link and repeat the process.
>
> This works fine for many sites, but doesn't work well in certain cases
> (e.g. when link doesn't generate HTTP request because it is internal
> javascript).
> Question: Is it possible to somehow clone an existing Browser control
> instead of creating a new one? The cloned Browser would need to contain
> not only the existing page content, but also any registered DOM event
> handlers (e.g. javascript) and possibly any other dynamic state created by
> the browser.
>
> Thanks,
> Gary
Re: Possible to clone browser control? [message #668436 is a reply to message #668382] Thu, 05 May 2011 16:32 Go to previous messageGo to next message
Gary is currently offline GaryFriend
Messages: 3
Registered: May 2011
Junior Member
Thanks for the reply.

I was hoping that I could mimic the functionality of the "Duplicate Tab" action in IE. This seems to do what I want, but I am not sure how it is done.

I notice in the SWT source code (IE.java) that the underlying Windows Browser object being manipulated by code like the following:

	int[] rgdispid = auto.getIDsOfNames(new String[] { "LocationURL" }); //$NON-NLS-1$
	int[] rgdispid = auto.getIDsOfNames(new String[] { "GoForward" }); //$NON-NLS-1$


Do you have a reference to the Windows documentation where the API ("LocationURL", "GoForward") is defined? Is it the WebBrowser Object at http://msdn.microsoft.com/en-us/library/aa752085%28v=VS.85%2 9.aspx?

Perhaps there is some clue as to our Duplicate Tab works in the browser control?

Thanks again,
Gary




Re: Possible to clone browser control? [message #668640 is a reply to message #668436] Fri, 06 May 2011 14:05 Go to previous message
Grant Gayed is currently offline Grant GayedFriend
Messages: 2150
Registered: July 2009
Senior Member
Yes, the link to MSDN you have is the correct one.

The WebBrowser control may or may not expose the functionality for doing
this (a quick glance doesn't find an obvious way). However for something
like this to become Browser API it would also need to be supported by the
Mozilla and WebKit implementations. If you only care about embedded IE and
are able to find a way to do this then you could hack your swt to expose its
"auto", and then go from there via COM invocations. It would be interesting
to see the solution if one is found.

Grant


"Gary" <ghirschhorn@fetch.com> wrote in message
news:ipuj0e$e6$1@news.eclipse.org...
> Thanks for the reply.
>
> I was hoping that I could mimic the functionality of the "Duplicate Tab"
> action in IE. This seems to do what I want, but I am not sure how it is
> done.
>
> I notice in the SWT source code (IE.java) that the underlying Windows
> Browser object being manipulated by code like the following:
>
>
> int[] rgdispid = auto.getIDsOfNames(new String[] { "LocationURL" });
> //$NON-NLS-1$
> int[] rgdispid = auto.getIDsOfNames(new String[] { "GoForward" });
> //$NON-NLS-1$
>
>
> Do you have a reference to the Windows documentation where the API
> ("LocationURL", "GoForward") is defined? Is it the WebBrowser Object at
> http://msdn.microsoft.com/en-us/library/aa752085%28v=VS.85%2 9.aspx?
>
> Perhaps there is some clue as to our Duplicate Tab works in the browser
> control?
> Thanks again,
> Gary
Previous Topic:DND images and offset not working?
Next Topic:Converting points using 'toControl' and 'toDisplay' gives wrong location on ubuntu10.10
Goto Forum:
  


Current Time: Thu Jul 09 09:41:53 GMT 2020

Powered by FUDForum. Page generated in 0.02126 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top