Salesforce VF标准取消按钮可用于经典或Lightning体验,但不能用于两个版本

Salesforce VF标准取消按钮可用于经典或Lightning体验,但不能用于两个版本,salesforce,visualforce,apex,Salesforce,Visualforce,Apex,我有一个带有保存和取消按钮的visualforce页面,我正在tab中打开这个表单。理想情况下,我想做的是当我点击cancel时,应该清除表单并关闭新打开的窗口本身 <apex:commandButton value=“cancel” action="{!cancel}" oncomplete=“window.close();” /> 上述声明在lightning体验中运行良好(窗口关闭),但在经典版本中不起作用 <apex:commandButton value=“ca

我有一个带有保存和取消按钮的visualforce页面,我正在tab中打开这个表单。理想情况下,我想做的是当我点击cancel时,应该清除表单并关闭新打开的窗口本身

<apex:commandButton value=“cancel” action="{!cancel}" oncomplete=“window.close();” />

上述声明在lightning体验中运行良好(窗口关闭),但在经典版本中不起作用

<apex:commandButton value=“cancel” action=“{!Mycancel}" oncomplete=“window.close();” />

您可以在javascript中检测它是经典还是闪电

 if(document.referrer.indexOf(".lightning.force.com") > 0){
        alert("This is lightning ");
    }else{
        alert("This is classic");
    }
看看这个