Finding subdomain of server content is running on

Jul 02, 2019

Is there any way to access the subdomain or domain from within the storyline content?

For example, I'd like to change some text based on if the published content is running from test.domain.com or www.domain.com

 

Thanks,

Kelly

1 Reply
Matthew Bibby

Assuming that you only need this to work on the one domain, then this should do the trick for you:

var player = GetPlayer();
var h = location.hostname;
player.SetVar("Domain",h);

Keep in mind, domains are weird. If you want to write something that you could confidently say will work on all domains, then the above isn't really good enough. You'd be better to use the URI.js library to build something more robust. But hopefully, the above will works for you.

Here is a demo that shows this code running in Storyline.

The domain is stored in a Storyline variable called Domain so you can query this with Storyline triggers like this:

Hope that makes sense. Here is the .story file used to create the above example

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