Storyline 3 and the use of localStorage in different browsers
Sorry for what is about to be a long winded post, but I figure the more detail you have the better.
Firstly, I should point out I am not a programmer, but am not afraid to try and play around copying bits of code here and there and, as you’ll see, what I am trying to achieve works in at least one browser, so here it is.
I'm trying to use user names throughout a course I am currently building. Ah, easy you might say, but the course is anticipated to be so large that it has had to split over a number of different .story files, which are as followed:
1. Landing page.
2. Menu page.
3. Course Part A.
4. Course Part B.
5. Course Part C.
6. Course Part D.
7. Course Part……etc
On entering the Landing Page, the user puts in their forename and surname, which are saved as text variables, ‘user_forename’ and ‘user_surname’. These have been combined into a single text variable ‘learnername’. The reason for this is that the course can address the user informally using their forename, but when generating certificates, at the end of each Course Part, can use the variable ‘learnername’ to generate the name displayed on the certificate. All three variables are, therefore, intended to be carried across to each of the other published .story files using the localStorage inside the browser. So, when the user clicks a continue button on the published Landing Page, after first filling in their first and last name, they are hyperlinked to the Menu page (separate published .story file), where they are informally welcomed (%user_forename%) and asked to select one of the courses to complete. On selecting the required course, say Course Part A, they are then hyperlinked to the appropriate published .story file. Again the three variables are carried across in localStorage. On completing the course, a certificate is generated for that part of the course and they are then returned to the published Menu page, this way, they only ever have to put their name in once (assuming they don’t close the browser and lose the localStorage data).
So here is my problem. I can get the localStorage to work in some browsers, but not in others as follows:
(1) Local Storage values visible on Landing page, when viewed using developer tools (Shift + F9), but are not carried across when the hyperlink is activated and hence not to any of the other published .story files.
(2) Doesn’t appear to save the localStorage values when viewed using developer tools (F12), at least not under Storage>local Storage
Chrome Version 78.0.3904.108 (Official Build) (64-bit)
Firefox 71.0 (64-bit)
Edge Microsoft Edge 44.18362.449.0
Microsoft EdgeHTML 18.18362
Int Explorer Version: 11.475.18362.0
On the landing page –
//Combine fore and surnames to get full learnername
var player = GetPlayer();
var a= player.GetVar("user_forename");
var b= player.GetVar("user_surname");
var c= a+" "+b;
//Export to Browser Local Storage Data
On subsequently hyperlinked pages –
//Get data from Browser local storage
var player = GetPlayer();
var user_forename = localStorage.getItem('user_forename');
var user_surname = localStorage.getItem('user_surname');
var learnername = localStorage.getItem('learnername');
//Set the variable values within the course
So my question is this, since ‘Can I use, indicates localStorage is supported in all the browsers I am testing, why can I only get it to work fully in Chrome?
Sorry, I can't supply a copy of the .story files due to (a) security ratings and (b) their size
As a side note, there doesn’t appear to be much on this topic in the forum, so maybe this will help future users as well as myself.