Tuesday, April 16, 2013

Close Browser Window without Promt using javascript ADF (IE)

import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
import org.apache.myfaces.trinidad.util.Service;



    public void closeWindow() {
        // Add event code here...
        FacesContext facesContext = FacesContext.getCurrentInstance();
        ExtendedRenderKitService service =
            Service.getRenderKitService(facesContext,
                                        ExtendedRenderKitService.class);
        service.addScript(facesContext, "window.open('', '_self', ''); window.close();");

    }

6 comments:

grs said...

Hiee,
i have checked this code it is showing error at "Service ". What package should i add to it

grs said...

Thanks got it worked.. Thankz alot dude.

Anonymous said...

This works in IE and Chorme but not in FF(v30). In FF it gives error - 'Scripts may not close windows that were not opened by script.'

vidya said...

Hi Vijay,

Can i know how to call above method in jspx.

Thanks in Advance.

vidya said...

Please let me know..

Unknown said...

hi
i am using the above code . this code is working fine for me before login once i am login with my credentials i am not able to close the browser please suggest me

Thanks in advance