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

If I create a publication and post it to 2 different websites ( 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" or "Welcome  to home.tld" but I wouldn't have to create 2 versions of the same publication and hard code values 

4 Replies
Matthew Bibby

Hi Michael,

Give this a try:

var firstDot = window.location.hostname.indexOf('.');
var tld = ".net";
var isSubdomain = firstDot < window.location.hostname.indexOf(tld);
var domain;

if (isSubdomain == true) {
domain = window.location.hostname.substring(firstDot == -1 ? 0 : firstDot + 1);
else {
domain = window.location.hostname;
var player = GetPlayer();

Make sure you have created a text variable called domain in Storyline.

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();

Which gets you
Thisdomain is the domain value e.g.
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