Using Childbrowser. My case:
- haveing an index.html file and test.html.
- going to test.html
- start Childbrowser from test.html
- I press the “Done”-button on the top left corner
- Childbrowser is closing and returns to the last open page from my app, in this case www/test.hml
I want to redirect/forward Childbrowser to my index.html of phone gap? How can I do it?
js-file:
// Callback when the user chooses the ‘Done’ button
// called from native
ChildBrowser._onClose = function()
{
window.plugins.childBrowser.onClose();
};
Code Snippet from .m file:
- (void)closeBrowser
{
if (self.delegate != nil) {
[self.delegate onClose];
}
if ([self respondsToSelector:@selector(presentingViewController)]) {
// Reference UIViewController.h Line:179 for update to iOS 5 difference - @RandyMcMillan
[[self presentingViewController] dismissViewControllerAnimated:YES completion:nil];
} else {
[[self parentViewController] dismissModalViewControllerAnimated:YES];
}
}
- (IBAction)onDoneButtonPress:(id)sender
{
[self closeBrowser];
NSURLRequest* request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"about:blank"]];
[self.webView loadRequest:request];
}
And the other .m file:
- (void)close:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options // args: url
{
[self.childBrowser closeBrowser];
}
- (void)onClose
{
[self.webView stringByEvaluatingJavaScriptFromString:@"window.plugins.childBrowser.onClose();"];
}
In your onClose handler set document.location to index.html. Should be as simple as that.