Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Browser widget: Popup Blocking with VisibilityWindowListener or OpenWindowListener?
Browser widget: Popup Blocking with VisibilityWindowListener or OpenWindowListener? [message #449360] Mon, 24 January 2005 17:09 Go to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Hi (Chris),

referring to Snippet 173:

http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet173.java#dirlist

the popup is blocked inside the VisibilityWindowListener#show() Method.

But is'nt it possible to block the popup in an earlier event:

OpenWindowListener#open() also tells about the kind of webpage
(adressbar, menubar, ...)?

Any reasons why one should block the popup inside the
VisibilityWindowListener and not earlier in the
OpenWindowListener?

Regards,
Ben
Re: Browser widget: Popup Blocking with VisibilityWindowListener or OpenWindowListener? [message #449546 is a reply to message #449360] Wed, 26 January 2005 09:40 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Hm no comment yet. I am then going to open a bug report to update
Snippet 173. I think
handling the popup inside the OpenWindowListener has the big advantage
that is not
required to dispose any widget.

Ben

> Hi (Chris),
>
> referring to Snippet 173:
>
> http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.swt.sni ppets/src/org/eclipse/swt/snippets/Snippet173.java#dirlist
>
>
> the popup is blocked inside the VisibilityWindowListener#show() Method.
>
> But is'nt it possible to block the popup in an earlier event:
>
> OpenWindowListener#open() also tells about the kind of webpage
> (adressbar, menubar, ...)?
>
> Any reasons why one should block the popup inside the
> VisibilityWindowListener and not earlier in the
> OpenWindowListener?
>
> Regards,
> Ben
Re: Browser widget: Popup Blocking with VisibilityWindowListener or OpenWindowListener? [message #449593 is a reply to message #449546] Wed, 26 January 2005 20:58 Go to previous messageGo to next message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
Hi Ben,

>> But is'nt it possible to block the popup in an earlier event:
There's a reason, details below.

>> OpenWindowListener#open() also tells about the kind of webpage
>> (adressbar, menubar, ...)?
No. The fields addressbar, menubar... are only set from the
VisiblityWindowListener.show notification.
Why? Some native browsers request a new window first, and - only after that
new browser instance is set - inform that new browser instance on the styles
it should use before getting visible. That's why you don't get that info in
the OpenWindowListener.open notification - it's not always known at that
stage.

Chris
Re: Browser widget: Popup Blocking with VisibilityWindowListener or OpenWindowListener? [message #449595 is a reply to message #449593] Wed, 26 January 2005 21:33 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Christophe Cornu wrote:

>Hi Ben,
>
>
>
>>>But is'nt it possible to block the popup in an earlier event:
>>>
>>>
>There's a reason, details below.
>
>
>
>>>OpenWindowListener#open() also tells about the kind of webpage
>>>(adressbar, menubar, ...)?
>>>
>>>
>No. The fields addressbar, menubar... are only set from the
>VisiblityWindowListener.show notification.
>Why? Some native browsers request a new window first, and - only after that
>new browser instance is set - inform that new browser instance on the styles
>it should use before getting visible. That's why you don't get that info in
>the OpenWindowListener.open notification - it's not always known at that
>stage.
>
>
Hm, but its working here on Windows. Is the late notification of styles
a problem
on Linux / Mac?

The whole popup problem would be no problem at all, if somehow one could
distinguish
between a new browser window being opened by a "target=_blank" link or
JavaScript.
Would it somehow be possible to store this information inside the
OpenWindowListener?

Ben


>Chris
>
>
>
>
Re: Browser widget: Popup Blocking with VisibilityWindowListener or OpenWindowListener? [message #449597 is a reply to message #449595] Wed, 26 January 2005 22:21 Go to previous messageGo to next message
Christophe Cornu is currently offline Christophe CornuFriend
Messages: 304
Registered: July 2009
Senior Member
> Hm, but its working here on Windows. Is the late notification of styles a
> problem
> on Linux / Mac?
Maybe we are not talking exactly about the same thing. The snippet below
will always display "false" for the values of addressBar and menuBar. Even
on Windows. Particularly on Windows since Internet Explorer fires that
information to the new native instance only after it has been created - and
not when initially firing the window open request (what Microsoft calls the
NewWindow2 event or even the most recent NewWindow3). The javadoc for the
OpenWindowListener.open mentions that only WindowEvent.browser and
WindowEvent.widget are set.

import org.eclipse.swt.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.browser.*;

public class PRBrowser {

public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
shell.setText("PRBrowser");
shell.setLayout(new FillLayout());
Browser browser = new Browser(shell, SWT.NONE);
browser.addOpenWindowListener(new OpenWindowListener() {
public void open(WindowEvent event) {
System.out.println("These fields are never set from
OpenWindowListener.open (only in VisibilityWindow.show:");
System.out.println("addressBar "+event.addressBar);
System.out.println("menuBar "+event.menuBar);
}
});
browser.setUrl("http://www.eclipse.org");
shell.open();

while (!shell.isDisposed()) {
try {
if (!display.readAndDispatch())
display.sleep();
} catch (Exception e) {}
}
}
}

> Would it somehow be possible to store this information inside the
> OpenWindowListener?
If/when there is a way to get that information on the different platforms,
this could be considered. If anyone knows a way that you think we may have
overlooked, please open a bug report or talk about it on the SWT developer's
mailing list.

Chris
Re: Browser widget: Popup Blocking with VisibilityWindowListener or OpenWindowListener? [message #449652 is a reply to message #449597] Thu, 27 January 2005 14:32 Go to previous messageGo to next message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Ah ok I am now understanding the problem. Those fields are always false
in the OpenWindowListener, regardless
if the Window is a popup or not.

Anyways, being able to block any javascript-window will allow to get rid
of all popups. Some time ago, I opened
a bug report on the issue: "Distinguish between popup and target = blank
link"

https://bugs.eclipse.org/bugs/show_bug.cgi?id=63233

This would be a killer feature that would allow to avoid the most
annoying problem of IE: popups

Ben

>>Hm, but its working here on Windows. Is the late notification of styles a
>>problem
>>on Linux / Mac?
>>
>>
>Maybe we are not talking exactly about the same thing. The snippet below
>will always display "false" for the values of addressBar and menuBar. Even
>on Windows. Particularly on Windows since Internet Explorer fires that
>information to the new native instance only after it has been created - and
>not when initially firing the window open request (what Microsoft calls the
>NewWindow2 event or even the most recent NewWindow3). The javadoc for the
>OpenWindowListener.open mentions that only WindowEvent.browser and
>WindowEvent.widget are set.
>
>import org.eclipse.swt.*;
>import org.eclipse.swt.widgets.*;
>import org.eclipse.swt.layout.*;
>import org.eclipse.swt.browser.*;
>
>public class PRBrowser {
>
> public static void main(String[] args) {
> Display display = new Display();
> Shell shell = new Shell(display);
> shell.setText("PRBrowser");
> shell.setLayout(new FillLayout());
> Browser browser = new Browser(shell, SWT.NONE);
> browser.addOpenWindowListener(new OpenWindowListener() {
> public void open(WindowEvent event) {
> System.out.println("These fields are never set from
>OpenWindowListener.open (only in VisibilityWindow.show:");
> System.out.println("addressBar "+event.addressBar);
> System.out.println("menuBar "+event.menuBar);
> }
> });
> browser.setUrl("http://www.eclipse.org");
> shell.open();
>
> while (!shell.isDisposed()) {
> try {
> if (!display.readAndDispatch())
> display.sleep();
> } catch (Exception e) {}
> }
> }
>}
>
>
>
>>Would it somehow be possible to store this information inside the
>>OpenWindowListener?
>>
>>
>If/when there is a way to get that information on the different platforms,
>this could be considered. If anyone knows a way that you think we may have
>overlooked, please open a bug report or talk about it on the SWT developer's
>mailing list.
>
>Chris
>
>
>
>
Re: Browser widget: Popup Blocking with VisibilityWindowListener or OpenWindowListener? [message #449653 is a reply to message #449652] Thu, 27 January 2005 14:36 Go to previous message
Benjamin Pasero is currently offline Benjamin PaseroFriend
Messages: 337
Registered: July 2009
Senior Member
Here are two other bug reports that would also help in the fight vs popups:

49696 [browser] Mouse event listeners does not work in SWT Browser Widget
https://bugs.eclipse.org/bugs/show_bug.cgi?id=49696

55351 [browser] link listener
https://bugs.eclipse.org/bugs/show_bug.cgi?id=55351

Ben
Previous Topic:Redrawing pixels to the screen in SWT-simple graphics prob
Next Topic:SWT-WebBrowser Control: PostData problem
Goto Forum:
  


Current Time: Fri Mar 29 11:57:35 GMT 2024

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

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

Back to the top