WindowsPhone8-Javascript:后退按钮
我需要处理WindowsPhone8的HTML5-Javascript应用程序中的后退按钮。我在C#中找到了很多解决方案,但在Javascript中没有找到。WindowsPhone8-Javascript:后退按钮,javascript,html,windows-phone-8,back-button,Javascript,Html,Windows Phone 8,Back Button,我需要处理WindowsPhone8的HTML5-Javascript应用程序中的后退按钮。我在C#中找到了很多解决方案,但在Javascript中没有找到。 有人知道怎么做吗?如果您使用的是PhoneGap,请看一下这是我在windows phone 7和8上使用的代码 //WPback button handler methods $(document).ready(function() { document.addEventListener("deviceready", setOverri
有人知道怎么做吗?如果您使用的是PhoneGap,请看一下这是我在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
}
//硬件后退按钮可以使用此按钮进行处理
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
});
很抱歉,我没有使用PhoneGap。我尝试了这个,但当我单击“上一步”按钮时,仍然会退出应用程序。我只需要把这段代码放到我的应用程序中,对吗?你必须把这段代码放到你的js文件中,并把它称为a the beginingTanks a lot@dpfauwadel,你刚刚救了我一天。其他用户注意:您可以在backbuttonap()中编写操作代码:我一直在到处寻找解决方案。非常感谢。