Lectora Hacks: Take Me Back (Even If I Wander)

August 30, 2017

Hack: save a bookmark for a page in a course and then jump back to that page later, from anywhere else in the course.

 

Why I needed this hack:

 

  • I wanted a student to be able to launch into a set of branch-out pages from anywhere in the course; and then give them a button to go back to where they left off after a wander through the branch-out pages.
     

  • So the old favourite piece of JavaScript, window.history.back() or window.history.go(-1) isn't enough to bring the wanderer back!

 


There are three parts to this hack:

 

  1. Create a new variable to store the "hold my place" bookmark.
     

  2. On the button which takes you to the branch-out pages, add an action to store the current location in the new variable.
     

  3. In the branch-out pages, provide some sort of "take me back" navigation using the bookmark.


Pretty straightforward stuff, right?

 

Here's how it's done (and if you're struggling with this, don't worry, we can do it for you!)

 

 


Step 1


I created a Lectora variable called BookmarkBack (you can call it whatever you like!). Note that we will be using some small pieces of JavaScript to reference this, and so you need to know the exact case sensitive spelling of the variable. Looking for "BookMarkBack" will not find my variable!!

 

 

 

Step 2


Add a Run Javascript action before the GoTo action with the following JavaScript. This extracts the HTML file name from the URL to the current page. I have underlined the variable name. Be careful about the case and punctuation of all of this:

 

VarBookmarkBack.set(document.location.href.split("/").slice(-1));

 

 

 

Optional Step 2a


You can add another action to store the CurrentPageName into a variable (say BookmarkTitle) which you can use to display the plain language name of the page you came from to the user. Bear in mind that the contents of BookmarkBack won't be very readable, particularly if you choose "Convert page names to short ID-based names" when you publish.  In that case, html names of published pages look something like page73645.html.

 

 

 

Step 3


Create a "take me back" navigation link of some sort in your branch-out pages, and add a Run Javascript action on it as follows. I have underlined the variable name:

 

trivExitPage( VarBookmarkBack.getValue() , true );

 

Optionally, you could also maintain a second variable to bookmark your place in the break out page list and provide a way to jump back and forth between parallel tracks.

 

 

 

That's it! Publish and enjoy. Whichever page you branch out from, and however much you wander in the meantime, when you kick off the "take me back" action you will go back to the page you came from.


Click here to try out a published example.

 

 

Share on Facebook
Share on Twitter
Please reload

Related posts
Please reload

Featured Posts

December 20, 2017

Please reload

Search By Category
Please reload

Search By Tags
Please reload

Find out more about how we can help you
+44 (0)1959 543900 | enquiry@transition.co.uk |
  • Twitter - White Circle
  • Facebook - White Circle
  • Instagram - White Circle

The Old Chapel, 52 Paynesfield Road, Tatsfield, Kent, TN16 2BG

© Transition Associates Ltd. 2019. All rights reserved | Company number: 3332304
Registered address: The Old Chapel, 52 Paynesfield Road, Tatsfield, Kent, TN16 2BG, England

This site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies. Find out more