function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
dturkeldturkel 

S-Control to retrieve Tab Name/Context

Is there a way using an S-Control/Javascript to retrieve the Tab name that I'm on?
I have a common functionality that relies on data that must be retrieved different depending if I'm on the Account, Case, or Opportunity tabs.
 
Dave
Best Answer chosen by Admin (Salesforce Developers) 
CaptainObviousCaptainObvious

See if this helps:

 

var str=parent.frames.location; str+=""; var startPos=str.search("com/"); var objPrefix=str.substring(startPos+4,startPos+7); var objName; switch (objPrefix) { case("001"):objName="Account";break; case("006"):objName="Opportunity";break; case("500"):objName="Case";break; } alert(objName);

 

You'll have to add more cases to the switch to cover other tabs.

All Answers

CaptainObviousCaptainObvious

See if this helps:

 

var str=parent.frames.location; str+=""; var startPos=str.search("com/"); var objPrefix=str.substring(startPos+4,startPos+7); var objName; switch (objPrefix) { case("001"):objName="Account";break; case("006"):objName="Opportunity";break; case("500"):objName="Case";break; } alert(objName);

 

You'll have to add more cases to the switch to cover other tabs.
This was selected as the best answer
dturkeldturkel

I should have posted our solution, but it is essentially what you have provided.

Thanks!