1

I have a script which opens a new page in a new sub-tab on the Service Cloud Console, and another one that closes that same new page once it's done loading.

It works, but I need to click on the '< a >' element to get it running, how can I make it run automatically?

Here's what I got so far:

<apex:page >
<apex:includeScript value="/support/console/28.0/integration.js"/>
<apex:includeScript value="/support/console/35.0/integration.js"/>


<A HREF="#" onClick="testCloseTab();return false">
  Click here to open a console URL</A> 

  <script type="text/javascript">
/*This script opens the article in a new sub-tub*/

    if (typeof(srcUp) == 'function') {
     srcUp('/articles/en_US/Procedure/BSOD');
     testCloseTab();
   }
else{
 window.open('/articles/en_US/Procedure/BSOD');
 testCloseTab();
}
</script>

<script type="text/javascript">
/*This script closes this VF page*/
 var callback = function () {
   if (result.error) {
    alert("Error message is " + result.error);
  }
};
function testCloseTab() {
            //First find the ID of the current tab to close it
            sforce.console.getEnclosingTabId(closeSubtab);
          }

          var closeSubtab = function closeSubtab(result) {
            //Now that we have the tab ID, we can close it
            var tabId = result.id;
            sforce.console.closeTab(tabId, callback);
          };
 </script>
</apex:page>
1

I used a workaround suggested in SFDC Developer Forum by Ron Wild.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.