a001index and URL Variables

Hello Rockstars,

So I am playing with the notion of using a user's specific geolocation based on one of the many APIs out there. I got it working nicely in a test module but when we went to a regional test it all appeared to come out of one location - which makes sense because of our network infrastructure.

While poking through the developer tools of the web browser, I noticed that our LMS is sending URL level variables on the module's first load. For example:

https:///foo/bar/en/Andrew/a001index.html?localserver=ABCD

Is there anyway to pull that variable using a script inside of Lectora software (e.g. JavaScript action) or must I be inserting my JavaScript code into the a001index.html file and passing the variable through client side storage.

Discussion (5)

Yes, essentially you could have Lectora load a script to capture that data and assign it to a variable, then you would be able to access that variable in Lectora.

Great thank you @nmaharaj , however, how do I put that reference in the a001index.html file? I cannot find out where to put it.

Bump. Sorry to be one of those guys. Is there any way to add stuff to the a001index.html file without actually having to publish, extract the zip, edit the a001index.html file, and then recompress the package?

Try adding a title level On Show -> Run JavaScript action to fill a variable called ServerLocation

// assuming you have a Lectora Variable named ServerLocation

var urlParams = new URLSearchParams(myTop.location.search);

if (urlParams.has('localserver'))

undefinedVarServerLocation.set(urlParams.get('localserver'))

I'll give this a whirl and report back.