我在顶点控制器中有页面参考方法。我需要关闭当前的选项卡。
这是我的代码:
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();');
}
提前谢谢。
任何帮助都将不胜感激。
发布于 2019-04-26 00:58:42
当您检查Window.close()的文档时,您会发现原因:
只允许对使用window.open()方法的脚本打开的窗口调用此方法。如果没有脚本打开窗口,控制台中就会出现类似于此的错误:脚本可能不会关闭脚本未打开的窗口。
简而言之:浏览器不会让你。这并不是Salesforce或VF特有的。无论如何,Windows.close()
不会关闭一个选项卡,而是关闭整个浏览器窗口。
如果您想关闭控制台选项卡,这个问题/答案可能会提供您想要的内容。
https://stackoverflow.com/questions/55851306
复制相似问题