5

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?

1 Answer 1

4

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.

3
  • This definitely sounds like great idea. Let me try and see if this works. Thank you Commented Sep 18, 2013 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
    Commented Sep 18, 2013 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. Commented Sep 19, 2013 at 16:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .