Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
151
rated 0 times [  157] [ 6]  / answers: 1 / hits: 23429  / 11 Years ago, sun, march 3, 2013, 12:00:00

I open a new page with window.open(apphelp.html, _blank, location=no), and then it shows me a new window with my page. At the end of this page, I would like to put a close button so the user can come back to where they came from. I tried that with window.close() but it didn't work. Any suggestions?


More From » android

 Answers
52

I use a workaround...
Since the inAppBrowser can be closed only with the back button or trough javascript. I display a close button from serverside that will change the current url firing also the event 'loadstop' letting to use the .close() method, in this way only the child browser will be closed, your app will remain in the same state.



For example my server display a webpage with a close button, something like this:



<a href=/mobile/close>Close</a>


in my client side javascript (the Phonegap app):



var ref = window.open(encodeURI(url), '_blank', options);
ref.addEventListener('loadstop', function(event) {
if (event.url.match(mobile/close)) {
ref.close();
}
});

[#79869] Friday, March 1, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
paola

Total Points: 675
Total Questions: 115
Total Answers: 95

Location: Laos
Member since Tue, Jul 7, 2020
4 Years ago
;