I have 3 Custom Console Components and 3 PrimaryTabs(visualforce pages) in my Service Cloud Console. What I am trying to define is a global Javascript variable which I want to access in any of the Components or Visualforce pages that I define as tabs?

Does anyone know if there is a way I can do that?

Or is there a way i can use addEventListener & fireEvent to pass back and forth the variables from one iframe to another?


How about using local storage? E.g.

localStorage.setItem("globalVarName", "value as string");
var globalVarVal = localStorage.getItem("globalVarName");

This value will persist even after the browser is closed, however I'm sure you could alter this behaviour if not desired. Check out http://diveintohtml5.info/storage.html for more info.

  • This definitely sounds like great idea. Let me try and see if this works. Thank you Sep 18 '13 at 1:02
  • One another point to be noted is that visualforce pages are served from a different domain(yourinstance.visual.force.com) than that of the standard pages(which are served from yourInstance.salesforce.com domain). Since localstorage obeys the same-origin-policy you cannot use the localstorage created from domain on another. You would probably need to have 2 localstorages, one for each domain.
    – Sam
    Sep 18 '13 at 4:23
  • I still didnt figure out a way to get the cross domain stuff working, but your way of localStorage did help me out with accessing variables originating from same domain. Sep 19 '13 at 16:59

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.