I have a modal that uses an iframe which leads to a vf page. There is a cancel button that I created whose functionality is to close the page. I have tried window.top.close. Any other reccommendations on how to make my vf page close? I also tried to get the enclosing tabId

<apex:commandButton value="Cancel" immediate="true" onclick="cancelModalDialog()"/>

function cancelModalDialog(){
        //var data = new Object(); 
        //data.execute = "setNeedToRefresh(false);";
        //window.parent.postMessage(JSON.stringify(data), '*'); 
        //    execute: 'sfdcPage.getDialogById(\'{!$CurrentPage.parameters.dialogid}\').cancel();'
        //}), '*');

        sforce.console.getEnclosingTabId(function closeSubtab(result) {
            //Now that we have the tab ID, we can close it
            var tabId = result.id;


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.