Search code examples
lotus-notesxpageslotus-dominolotusserverside-javascript

window.close() in XPages


I am having a Xpage with some links. One of my link call EXIT having window.close() to close the current tab in browser.

In browser when I am opening the document(Xpage holds the document) from the view and clicking on the EXIT link, it closes the current tab/window.

Whereas, I am redirecting the same xpage from SSJS using context.redirectToPage() . When I clicking on the EXIT link, it is not closing the tab/window.

In Javascript console: Scripts may not close windows that were not opened by script

Anyone help me.

Thanks in Advance, Karthick


Solution

  • As the Javascript console says: Window.close() needs a window.open() to work.

    See http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Whats_New_in_852_for_XPages#window.close%28%29+support

    Update: You can create your response document using client-side JS - including opening the window. The following will do that:

    // get parent document id    
    docid='#{javascript:document.getNoteID()}';
    
    // create the URL
    url="response.xsp?action=newDocument&parentId="+docid;
    
    // open a new window with the response document
    window.open(url);