Support Article
'Are you sure you want to leave?' displays on closing browser
Summary
A browser popup 'Are you sure you want to leave?' displays when closing the browser.
Error Messages
Not Applicable.
Steps to Reproduce
- Create a portal
- Refer a custom JS file in a harness rule and include following script:
function closeOpenItems(e){
pega.desktop.closeAllDocuments(e);
}
if (window.addEventListener) {
window.addEventListener('beforeunload', closeOpenItems, false);
}else if (window.attachEvent) {
window.attachEvent('onbeforeunload', closeOpenItems); }
- Use Dynamic Container in the Work Area
- Open a tab with work object in Internet Explorer browser
- Close the Internet Explorer browser. The pop up displays
Root Cause
A software use or operation error. When using the custom script to close the tabs of Dynamic Container, the tabs close however, Dynamic Container cleanup does not occur in the browser.
Resolution
Perform the following local-change:1. Create an activity with the following Java source and When condition:
Java Source:
String portalName = tools.getParamValue("portalName");
ClipboardPage pg_decPage = tools.findPage("Declare_pyDisplay",true);
if(pg_decPage != null){
ClipboardProperty cp_pyDisplay = pg_decPage.getProperty("pyDisplay");
if(cp_pyDisplay != null ){
cp_pyDisplay.remove(portalName);
}
}
When condition: Param.portalName != ""
2. Call the activity during window unload using the following script:
function closeOpenItems(e){
var safeURL = new SafeURL();
var portalName = pega.u.d.portalName;
if(portalName){
safeURL.put("pyActivity","ClearDataModel");
safeURL.put("portalName",portalName);
pega.u.d.asyncRequest("POST", safeURL, null, null, {"bAsync":false});
}
}
window.onbeforeunload = function (e) {
closeOpenItems(e);
}
Published September 13, 2018 - Updated October 8, 2020
Have a question? Get answers now.
Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.