Call custom Javascript from page.load
I have this simple code to start with, and I want to fire it on each page thats loaded, but it seems to not fire at all and I cannot understand why.
Here is the function:
precode
book = {};
book = {
"intro" : [{
"bookName" : "The Books Name"
}],
Code: Select all
"page1": [{
"text" : "This is the text that will be displayed on page 1 of the book.",
"images" : {
"image1" : 'localfile to image',
"image2" : 'localfile to image',
"image3" : 'localfile to image'
}
}],
"page2": [{
"text" : "This is the text that will be displayed on page 1 of the book.",
"images" : {
"image1" : 'localfile to image',
"image2" : 'localfile to image',
"image3" : 'localfile to image'
}
}],
"page3": [{
"text" : "This is the text that will be displayed on page 1 of the book.",
"images" : {
"image1" : 'localfile to image',
"image2" : 'localfile to image',
"image3" : 'localfile to image'
}
}],
"page4": [{
"text" : "This is the text that will be displayed on page 1 of the book.",
"images" : {
"image1" : 'localfile to image',
"image2" : 'localfile to image',
"image3" : 'localfile to image'
}
}],
"page5": [{
"text" : "This is the text that will be displayed on page 1 of the book.",
"images" : {
"image1" : 'localfile to image',
"image2" : 'localfile to image',
"image3" : 'localfile to image'
}
}],
"page6": [{
"text" : "This is the text that will be displayed on page 1 of the book.",
"images" : {
"image1" : 'localfile to image',
"image2" : 'localfile to image',
"image3" : 'localfile to image'
}
}] };
//console.log(book.page1[0].text);
function GetText(page) {
Code: Select all
console.log(page);
var pText;
switch(page) {
case "p1" :
pText = book.page1[0].text;
break;
case "p2" :
pText = book.page2[0].text;
break;
}
console.log(pText); }
/code/pre
On the pages, I have this:
The console.log above the function shows the text as it should, but any console.log in the function is not fired. I have tried:
precode
var GetText = function(page) {
/code/pre
precode
GetText = function(page) {
/code/pre
None seem to fire though, any reason this would not work in Appery ?