Dynamic button/link

Oct 23, 2020

Anyone know of a way for a button to pull from the current url?

I'd like to be able to parse this url and have a button linked to the course page. 

For example, if a user in a lesson and the current url is www.mydomain.com/courses/my-course/lesson/my-lesson and I want a link/button to be linked to www.mydomain.com/courses/my-course.

This is essentially helps me reduce the number of courses I need to maintain and customize this button for each course. 

Thank you! 

1 Reply
Dave Cox

Hi Jennifer,

It sounds like you are want to navigate to a particular slide or scene in Storyline based on the value in the URL.

If you are accessing your course from a web site, you can do what you are requesting, but it will take some work in Javascript on the first slide of your project. This probably will not work from an LMS. Assuming you are comfortable with javascript, the following steps should get you started.

  1. The first step is to add a parameter to your URL For example, you may "slide=1" by changing your URL to www.mydomain.com/courses/my-course.html?slide=1. Note the "?" character. That character is critical to making this work.
  2. Next, you can read the URL that called your course with javascript with the following statement: var url = window.location.href  This places the URL string in the variable "url".
  3. Next, you have to separate the URL from the parameter. You can use the javascript split() function to extract the parameter
  4. Then you need to extract the slide value from the slide parameter. You can again use the split() function to separate the string "Slide=" from the value.
  5. Now you can use load your javascript variable into a storyline variable using Storyline's player.GetVar() functions.
  6. Now that you have the value in Storyline, it is a simple matter to jump to the correct slide using triggers within the first slide in Storyline.

Best regards,

Dave

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