Windows Phone 8 - Javascript:后退按钮

Windows Phone 8 - Javascript : back button

本文关键字:按钮 Javascript Phone Windows      更新时间:2023-09-26

我需要处理后退按钮在HTML 5 - Javascript应用程序为Windows Phone 8。我在c#中找到了很多解决方案,但在Javascript中没有。有人知道怎么做吗?

//硬件返回按钮可以使用这个来处理。

 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
    });

这是我在windows phone 7上工作的代码;8

//WPback button handler methods
$(document).ready(function()
{
document.addEventListener("deviceready", setOverrideBackbutton, false);
});
function setOverrideBackbutton()
{
document.addEventListener("backbutton", backButtonTap, true);
}
/**
 * Callback after a backbutton tap on windows platforms.
 * Do nothing.
 */
function backButtonTap()
{
//Do not remove
}

如果您正在使用PhoneGap,请查看http://www.risingj.com/archives/493