Question

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

Was it helpful?

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);

OTHER TIPS

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

Thats you're answer to the question. Javascript can't close tabs / windows which are not created by javascript.

You could try the following:

How to close browser window

you can try this trick im using.

window.open('', '_self', '');

window.close();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top