CB-3324 Add support for back-button inappbrowser [WP8] if there is no history -> InAppBrowser is closed

This commit is contained in:
Jesse MacFadyen 2014-04-14 17:11:36 -07:00
parent 34c29dc2ec
commit 1c32236353

View File

@ -331,6 +331,8 @@ namespace WPCordovaClassLib.Cordova.Commands
bar.IsVisible = !StartHidden;
AppBar = bar;
page.BackKeyPress += page_BackKeyPress;
}
}
@ -338,6 +340,23 @@ namespace WPCordovaClassLib.Cordova.Commands
});
}
void page_BackKeyPress(object sender, System.ComponentModel.CancelEventArgs e)
{
#if WP8
if (browser.CanGoBack)
{
browser.GoBack();
}
else
{
close();
}
e.Cancel = true;
#else
browser.InvokeScript("execScript", "history.back();");
#endif
}
void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
@ -405,8 +424,10 @@ namespace WPCordovaClassLib.Cordova.Commands
grid.Children.Remove(browser);
}
page.ApplicationBar = null;
page.BackKeyPress -= page_BackKeyPress;
}
}
browser = null;
string message = "{\"type\":\"exit\"}";
PluginResult result = new PluginResult(PluginResult.Status.OK, message);