Skip to main content

This content has been archived and is no longer being updated. Links may not function; however, this content may be relevant to outdated versions of the product.

Support Article

'Are you sure you want to leave?' displays on closing browser



A browser popup 'Are you sure you want to leave?' displays when closing the browser.

Error Messages

Not Applicable.

Steps to Reproduce

  1. Create a portal
  2. Refer a custom JS file in a harness rule and include following script:
    function closeOpenItems(e){ 

    if (window.addEventListener) { 
    window.addEventListener('beforeunload', closeOpenItems, false); 
    }else if (window.attachEvent) { 
    window.attachEvent('onbeforeunload', closeOpenItems); } 

  3. Use Dynamic Container in the Work Area
  4. Open a tab with work object in Internet Explorer browser
  5. 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.


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

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;
    pega.u.d.asyncRequest("POST", safeURL, null, null, {"bAsync":false});

 window.onbeforeunload = function (e) {  


Published September 13, 2018 - Updated October 8, 2020

Was this useful?

0% found this useful

Have a question? Get answers now.

Visit the Collaboration Center to ask questions, engage in discussions, share ideas, and help others.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Community has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice
Contact us