When Im opening a page in the childbrowser on page1 I want to run a function when I close it, and it works. But when I go to page2 and open another page in the childbrowser it runs the function here as well and I dont want that.
So how can I run a function when I close the childbrowser on just page1 and not on page2?
Im using this on page1 to run the function when Im closing the CB.
var apptypen='iPhone';
$(document).ready(function(){
if (apptypen=='iPhone'){
alert("apptype iphone");
window.plugins.childBrowser.onClose=function(){
jQT.goBack(1);
window.plugins.childBrowser.onClose = null;
}
}
});
When I opens the CB on page1 it runs the alert and it goes back with the jQT.goBack(1); function, but if I open the CB on page2 it doesent run the alert, but it does run the jQT.goBack, and thats what I dont want. It should only run jQT.goBack when I open the CB on page1 and not when I open a page in the CB on page2. Any input appreciated, thanks. Solved, I had to have window.plugins.childBrowser.onClose = null; after the jQT.goBack.
You'll want to register a location change listener. Then when you move to page 2 you can set a global variable or remove the close listener. Your choice.
window.plugins.childBrowser.onLocationChange = function(loc) {
if (loc == "page1.html") {
window.plugins.childBrowser.onClose = function() {
alert("close");
};
} else if (loc == "page2.html") {
window.plugins.childBrowser.onClose = null;
}
};