Windows Phone 8 - Javascript:后退按钮
问题描述:
我需要处理HTML 5中的后退按钮 - Windows Phone 8的Javascript应用程序。我在C#中找到了很多解决方案但在Javascript中没有人。
有人知道怎么做吗?
I need to handle the back button in HTML 5 - Javascript application for Windows Phone 8. I found a lot of solutions in C# but no one in Javascript. Does anybody know how to do this ?
答
//可以使用此处理硬件后退按钮。
//Hardware back button could be handle using this.
var hardwareButtons = Windows.Phone.UI.Input.HardwareButtons;
hardwareButtons.addEventListener("backpressed", function (e) {
e.handled = true; //handle back button event(won't close the app).
history.back(); //go back to history
});