Salesforce Window.close在页面引用顶点方法中不工作
我有apex控制器中的页面引用方法。 我需要关闭当前选项卡 这是我的密码:Salesforce Window.close在页面引用顶点方法中不工作,salesforce,apex,apex-code,visualforce,salesforce-service-cloud,Salesforce,Apex,Apex Code,Visualforce,Salesforce Service Cloud,我有apex控制器中的页面引用方法。 我需要关闭当前选项卡 这是我的密码: public PageReference savePostSurveyAnswer(){ String sitePathPrefix = Site.getPathPrefix(); System.debug('savePostSurveyAnswer method start'); CaseIdentifierIdValue = ApexPages.currentPage
public PageReference savePostSurveyAnswer(){
String sitePathPrefix = Site.getPathPrefix();
System.debug('savePostSurveyAnswer method start');
CaseIdentifierIdValue = ApexPages.currentPage().getParameters().get('caseIdentifierId');
ShGl_PostChatSurvey__c postChatSurvey = new ShGl_PostChatSurvey__c();
postChatSurvey.ShGl_SurveyQuestion1__c = question1;
postChatSurvey.ShGl_SurveyQuestion2__c = question2;
postChatSurvey.ShGl_SurveyQuestion3__c = question3;
postChatSurvey.ShGl_SurveyQuestion4__c = question4;
postChatSurvey.ShGl_SurveyResponse1__c = questionAnsSelected1;
postChatSurvey.ShGl_SurveyResponse2__c = questionAnsSelected2;
postChatSurvey.ShGl_SurveyResponse3__c = questionAnsSelected3;
postChatSurvey.ShGl_SurveyResponse4__c = questionAnsSelected4;
postChatSurvey.ShGl_Market_Code__c = 'US'; //new data base model
postChatSurvey.ShGl_UniqueCaseIdentifier__c = CaseIdentifierIdValue;
//postChatSurvey.ShGl_LiveTranscriptChatKey__c = chatKeyIdValue;
//postChatSurvey.ShGl_CaseOfSurvey__c = (Id) LiveChatTranscriptObj.CaseId; //through trigger
Database.SaveResult postSaveResult = Database.insert(postChatSurvey);
return new PageReference('javascript:window.close();');
}
提前谢谢
任何帮助都将不胜感激。当您查看文档时,您将发现原因: 仅允许对使用window.open()方法的脚本打开的窗口调用此方法。如果窗口不是由脚本打开的,则控制台中会出现与此类似的错误:脚本可能无法关闭未由脚本打开的窗口 简而言之:浏览器不允许您使用。这并不特定于Salesforce或VF
Windows.close()
无论如何都不会关闭选项卡,而是关闭整个浏览器窗口
如果您希望关闭控制台选项卡,则可能会提供所需内容