childBrowser not running
Forget above, it works on device, just not when testing in the browser...
Catch up wih the Appery.io community on our forum. Here you'll find information on the lastest questions and issues Appery.io developers are discussing.
https://forum.appery.io/
Forget above, it works on device, just not when testing in the browser...
Hi David,
Thank you for the update!
Hi Igor
Thanks for response...
I am still at the learning/testing phase at the moment but enjoying the experience.
If I use the below code:
window.plugins.childBrowser.showWebPage(localStorage.getItem('var_bar_text'),{ showLocationBar: false });
alert(localStorage.getItem('var_bar_text'));
I was just using the Alert to see how far through the code I am getting, however the Alert comes up at the same time as the browser..
How would I make the code wait until the browser was closed before continuing with execution ?
Thanks
David
Hi David,
Run the following:
codewindow.plugins.childBrowser.onClose(function() {
alert(localStorage.getItem('var_bar_text'));
});/code
Thanks Katya .. That makes sense..
David. Thought I would share my child browser code with u.
Add code below to an existing JavaScript file or create a new one.
Then to open a child browser just call gotoMyPage(page);
page being the full web address.
eg. gotoMyPage('http://www.google.com');
code
function gotoMyPage(page) {
var startDate = new Date();
localStorage.setItem('ReadTime',startDate.getTime());
localStorage.setItem('viewingpage', page);
var cb = window.plugins.childBrowser;
window.plugins.childBrowser.onLocationChange = locationChanged;
window.plugins.childBrowser.onClose = closed;
window.plugins.childBrowser.showWebPage(page, { showLocationBar: false });
}
function locationChanged(newurl) {
var origional = localStorage.getItem('viewingpage');
if (origional.toString() == newurl.toString()) {
alert('Wait a moment.. Page is Loading...');
}
}
function closed() {
var secs = seconds_elapsed();
// CONVERT SECONDS TO MINUTES AND SECONDS
var mins = Math.floor(secs / 60);
secs -= mins * 60;
if (secs <10){secs = '0' + secs;}
localStorage.setItem('ReadTime', mins + "." + secs);
var readtime = mins + "." + secs;
var minread = 3.15;
var trackings = localStorage.getItem('trackreading');
if (trackings != 'NO') {
if (parseFloat(readtime) < minread) {
alert('You read for: ' + parseFloat(readtime) + '\nNOT POSTED AS READ..! You must spend at least ' + minread + ' reading this document!');
}else{
alert('Viewing Time is: ' + parseFloat(readtime) + '\nThis Document will be marked as Read...');
}
}
localStorage.removeItem('ReadTime');
localStorage.removeItem('viewingpage');
localStorage.setItem('trackreading', 'true');
}
function seconds_elapsed () {
var startTime = localStorage.getItem('ReadTime');
var date_now = new Date();
var time_now = date_now.getTime();
var time_diff = time_now - startTime;
var seconds_elapsed = Math.floor (time_diff /1000);
return (seconds_elapsed);
}
/code
Withe this code you can tell when they load, change and close pages.
Also how long they have been on the page...
The example I gave notifies the user if they have viewed long enough.
Keep in mind it only works on phones.
Thank you very much Neil
That is very kind of you..
I am really enjoying getting my head around programming for phones.
Lots of new challenges and lots of possibilities.
Best Regards
David
Your welcome David.
Have fun!!
Hi Max,
Does the Childbrowser function work in the test simulator on the mobile frame on the appery website (test). If it is suppose to work. All I have is a javascript on load that looks like this and its not working.
window.plugins.childBrowser.showWebPage('http://m.facebook.com');
The app has to be installed on the device.