SET A "GO BACK" BUTTON TO A SPECIFIC PAGE WITHOUT USING THE PREVIOUS PAGE FUNC..

ecuevas1195
ecuevas1195 Community Member Posts: 5
I was working on a course with a specific UX that the Glossary was in the same window without open an emerge window. So, the glossary included its own sections and the use of the Go To Previous Page function didn't work with the design and the expected functionality. The solution was made with three steps and javascript.
  1. Set the variable Bookmark in the page where the user clicked the glossary.
  2. Configure the Go Back button in the Glossary
  3. Run the GoBack function in javascript.
 
  1. In the page where the glossary button is, you have to include a RunJavascript function in the button:
//Defines the variable VarBookmarkBack
var VarBookmarkBack = new Variable( 'VarBookmarkBack', '0', 0, 0, null, null, 'page1.html' );

//Defines the function setBookmark for the page where the user goes to the Glossary.

function setBookmark(){
VarBookmarkBack.set(document.location.href.split("/").slice(-1));
}

//Use of the function
setBookmark();


2. In the Glossary you have to create a button to Go Back to the chapter, even if the user navigates through the glossary elements the user can go to the specific page where he or she clicked the glossary.

3. In the button Go Back put the next javascript code.

var VarBookmarkBack = new Variable( 'VarBookmarkBack', '0', 0, 0, null, null, 'page1.html' );

function takeMeBack(){
trivExitPage( VarBookmarkBack.getValue() , true );
}

takeMeBack();

//I defined the variable bookmark again, cause the lectora didn't recognize. So, you can use the page saved and go back to where you were.