Explore the community Forums Lectora Tips and tricks Navigation with java Script and variables Reply To: Navigation with java Script and variables

#401432 Score: 0
Profile photo of Math Notermans
Math Notermans
friend finder
junior moderator
LUC16 Attendee
wise owl
curious george
129 pts

Hi Benjamin, Trying to make something like this work i notice a few things to be aware of.
For example… if you use Chapters and Sections… well the html-name of your page will have those included.
For example i have a Chapter named ‘Dragged and drop with Javascript’ in which i now have 1 page called ‘Simple sample’. If i set the variable to CurrentPageName, it will be simply ‘Simple sample’  If i use that in the summary to get back to…well it fails..the page cannot be found…

I got a getBack(); function in my scripts that returns indeed to the proper last page visited.

function getBack(){
lastPageVisited = VarSummaryGoBack.getValue();
trivExitPage(lastPageVisited ,true);

Like this it will not work, trying to go back to the real name of the page… Simple sample in my example.
Taking however into account the Chapter and possibly Section your page is in it will work.
And as a extra from Trivantis…all uppercast characters will be converted to undercast and all spaces to _
So if your page is in a Chapter called ‘Drag and drop with Javascript’ and the page is called ‘Simple sample’
then the function below will get it back to that page.

function getBack(){
lastPageVisited = VarSummaryGoBack.getValue();
var test = “drag_and_drop_with_javascript_simple_sample.html”;

So what we need to do to get this working, is getting the proper name including chapters and sections and convert uppercast to undercast and replace spaces by _

I am working on a sample of this in Lectora Online, when its working i export a package and add it here.

Kind regards,

PS. there is also a variable called CurrentPageId.. gonna check what that one does…if there is some array of all pages, then i do think the CurrentPageId might get to the actual pagename…