首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
社区首页 >问答首页 >Window.close在页面引用Apex方法中不工作

Window.close在页面引用Apex方法中不工作
EN

Stack Overflow用户
提问于 2019-04-25 14:09:24
回答 1查看 1.4K关注 0票数 0

我在顶点控制器中有页面参考方法。我需要关闭当前的选项卡。

这是我的代码:

代码语言:javascript
代码运行次数:0
运行
复制
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();');
}

提前谢谢。

任何帮助都将不胜感激。

EN

回答 1

Stack Overflow用户

发布于 2019-04-26 08:58:42

当您检查Window.close()的文档时,您会发现原因:

只允许对使用window.open()方法的脚本打开的窗口调用此方法。如果没有脚本打开窗口,控制台中就会出现类似于此的错误:脚本可能不会关闭脚本未打开的窗口。

简而言之:浏览器不会让你。这并不是Salesforce或VF特有的。无论如何,Windows.close()不会关闭一个选项卡,而是关闭整个浏览器窗口。

如果您想关闭控制台选项卡,这个问题/答案可能会提供您想要的内容。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55851306

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档