David6064062
Posts: 0
Joined: Sat Jul 20, 2013 1:34 pm

childBrowser not running

Forget above, it works on device, just not when testing in the browser...

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

childBrowser not running

Hi David,

Thank you for the update!

David6064062
Posts: 0
Joined: Sat Jul 20, 2013 1:34 pm

childBrowser not running

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

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

childBrowser not running

Hi David,

Run the following:
codewindow.plugins.childBrowser.onClose(function() {
alert(localStorage.getItem('var_bar_text'));
});/code

David6064062
Posts: 0
Joined: Sat Jul 20, 2013 1:34 pm

childBrowser not running

Thanks Katya .. That makes sense..

Emmz
Posts: 0
Joined: Sat Jun 23, 2012 11:06 pm

childBrowser not running

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&#46;setItem('ReadTime', mins + "&#46;" + secs);
var readtime = mins + "&#46;" + secs;
var minread = 3&#46;15;
var trackings = localStorage&#46;getItem('trackreading');
if (trackings != 'NO') {
if (parseFloat(readtime) < minread) {
alert('You read for: ' + parseFloat(readtime) + '\nNOT POSTED AS READ&#46;&#46;! You must spend at least ' + minread + ' reading this document!');
}else{
alert('Viewing Time is: ' + parseFloat(readtime) + '\nThis Document will be marked as Read&#46;&#46;&#46;');
}
}
localStorage&#46;removeItem('ReadTime');
localStorage&#46;removeItem('viewingpage');
localStorage&#46;setItem('trackreading', 'true');
}
function seconds_elapsed () {
var startTime = localStorage&#46;getItem('ReadTime');
var date_now = new Date();
var time_now = date_now&#46;getTime();
var time_diff = time_now - startTime;
var seconds_elapsed = Math&#46;floor (time_diff &#47;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.

David6064062
Posts: 0
Joined: Sat Jul 20, 2013 1:34 pm

childBrowser not running

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

Emmz
Posts: 0
Joined: Sat Jun 23, 2012 11:06 pm

childBrowser not running

Your welcome David.
Have fun!!

John6122514
Posts: 0
Joined: Wed Aug 07, 2013 7:10 pm

childBrowser not running

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');

maxkatz
Posts: 0
Joined: Fri Aug 13, 2010 3:24 pm

childBrowser not running

The app has to be installed on the device.

Return to “Issues”