Can I define a global Javascript variable that I can access from all Custom Console Components in Service Cloud Console?

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?

Answer

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.

Attribution
Source : Link , Question Author : logontokartik , Answer Author : luke.mcfarlane

Leave a Comment