-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbackbutton.js
More file actions
41 lines (27 loc) · 1.24 KB
/
backbutton.js
File metadata and controls
41 lines (27 loc) · 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
(function(){
var webview = document.getElementById('webview');
var initURL;
//this is a cheat, probably only real way is to pull it from the manifest
setTimeout(function(){ initURL = webview.src + "";},1000)
// function to handle the system Navigation Event
function handleSystemNavigationEvent(args) {
if (webview.canGoBack == false) {
return;
}
webview.goBack();
}
// Initialize the code on Windows load
// setNavigationState();
var systemNavigationManager = Windows.UI.Core.SystemNavigationManager.getForCurrentView();
systemNavigationManager.addEventListener("backrequested", handleSystemNavigationEvent.bind(this));
var systemNavigation = Windows.UI.Core.SystemNavigationManager.getForCurrentView();
//set up event to show if you can
webview.addEventListener('MSWebViewDOMContentLoaded', function(){
if (webview.canGoBack == true && initURL != webview.src) {
systemNavigation.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.visible;
}
else{
systemNavigation.appViewBackButtonVisibility = Windows.UI.Core.AppViewBackButtonVisibility.collapsed;
}
});
})();