|
|
Re: Closing browser or browser-tab after workbench close [message #635947 is a reply to message #635870] |
Thu, 28 October 2010 16:42 |
Benjamin Wolff Messages: 136 Registered: July 2009 |
Senior Member |
|
|
I now know what is causing the problem. This simple snippet works in IE. It closes the the browser or browsertab without any further warnings:
Display.getCurrent().disposeExec(new Runnable() {
@Override
public void run() {
JSExecutor.executeJS("window.open('','_parent','');window.close(); ");
}
});
The problem with firefox is, that the setting "dom.allow_scripts_to_close_windows" under about:config defaults to false. So it is not allow
to close the browser window by script.
Setting
netscape.security.PrivilegeManager.enablePrivilege(”Univer salBrowserWrite”);
in the script does not work due to right limitations.
Hm, anyone knows if there is a workaround that does not include to configure each client browser (which is no option, unfortunately)?
Greetings,
Ben
Am 28.10.2010 14:40, schrieb Benjamin Wolff:
> After browsing through the RAP FAQ i tried this contruct in the preWindowOpen() Method:
>
> Display.getCurrent().disposeExec(new Runnable() {
> @Override
> public void run() {
> RWT.getLifeCycle().addPhaseListener(new PhaseListener() {
>
> private static final long serialVersionUID = 1L;
>
> @Override
> public PhaseId getPhaseId() {
> return PhaseId.RENDER;
> }
>
> @Override
> public void beforePhase(PhaseEvent event) {}
>
> @Override
> public void afterPhase(PhaseEvent event) {
> String jsCode = "parent.window.close();";
> try {
> ContextProvider.getStateInfo().getResponseWriter().write(jsC ode);
> } catch (IOException e) {
> e.printStackTrace();
> }
> RWT.getLifeCycle().removePhaseListener(this);
> }
> });
> }
> });
>
> The idea is, before disposing the display the phaselistener is registered. After the RENDER phase
> it gets executed but the call to ContextProvider.getStateInfo().getResponseWriter().write(jsC ode);
> does not have any effect. I tried using the RWT.getResponse().getWriter() method, but this throws an
> IllegalStateException. I assume that this method was already called?!
> Can someone tell me what i'm missing here or if this is the right approach?? ;))
>
> Greetings,
> Ben
>
>
> Am 28.10.2010 12:45, schrieb Benjamin Wolff:
>> Hi,
>>
>> is there a possibility to close the browser or browser-tab after the workbench is closed?
>> I know, that there is a JavaScript command for that. Has anyone tried that or can give
>> me a hint where i should try to send the JavaScript code?
>>
>> Greetings,
>> Ben
|
|
|
Powered by
FUDForum. Page generated in 0.03397 seconds