Is it possible to get the location (url) of where a publication is hosted to use within storyline

Apr 29, 2016

If I create a publication and post it to 2 different websites ( domain.xyz and home.tld) is there a way either using javascript or other methods in SL2 for a slide in the publication to know its host/published location e.g could I have a text entry update with "Welcome to %domain" and depending on which site I visited I would get "Welcome to domain.xyz" or "Welcome  to home.tld" but I wouldn't have to create 2 versions of the same publication and hard code values 

2 Replies
Michael O'Brien

Hi Matthew,

Thanks for responding. Your solution is more elegant than I actually need but it did point me to window.location so really appreciate that as javascript is not my strong point

My solution is

var Thisdomain;
var ThisPage;
Thisdomain = window.location.hostname;
ThisPage = window.location.pathname;
var player = GetPlayer();
player.SetVar("Domain",Thisdomain);
player.SetVar("HostPage",ThisPage);

Which gets you
Thisdomain is the domain value e.g. myhost.com
ThisPage is the path to the html file created by articulate and used to launch the publication e.g. /folder/story_html5.html or where ever on the host the file is saved

This discussion is closed. You can start a new discussion or contact Articulate Support.