-- 作者:有点甜
-- 发布时间:2017/9/22 11:22:00
--
以下是引用yjf123在2017/9/22 10:26:00的发言: 怎么设置手机返回键为浏览后退,不是直接退出app呢
web/weui目录下weui.me.js文件,修改onload函数
function onload() { var eles = document.getElementsByClassName("weui_mask_transition"); for (var i = 0; i < eles.length; i++) { eles[i].addEventListener("transitionend", hideActionMask); } eles=document.getElementsByClassName("fox_table") for (var i = 0; i < eles.length; i++) { eles[i].onmousedown=tableMouseDown; eles[i].rowSel = -1; eles[i].colSel = -1; if(eles[i].hasAttribute("data-pagenumber")){ eles[i].pagenumber=eles[i].attributes["data-pagenumber"].value; } } eles = document.getElementsByClassName("weui-gallery__img"); for (var i = 0; i < eles.length; i++) { eles[i].onclick = galleryClick; } eles = document.querySelectorAll(".weui_uploader_files,.article_image"); for (var i = 0; i < eles.length; i++) { eles[i].onclick = showGallery; } eles = document.querySelectorAll("[data-tab-page]"); for (var i = 0; i < eles.length; i++) { eles[i].onclick = tabClick; } eles = document.querySelectorAll(".fox_actionsheet,.weui_dialog_ft"); for (var i = 0; i < eles.length; i++) { eles[i].onclick = hide; } eles = document.getElementsByClassName("weui-gallery__del"); for (var i = 0; i < eles.length; i++) { eles[i].onclick = galleryDelete; } eles=document.getElementsByTagName("form"); for(var i=0;i<eles.length;i++){ if(eles[i].querySelector(".weui_uploader_input[data-incremental]")){ eles[i].incremental = true; eles[i].onreset=resetForm; var fluds=eles[i].getElementsByClassName("weui_uploader_input"); for(var idx=0;idx<fluds.length;idx++){ fluds[idx].Files = []; } } } var eles = document.getElementsByClassName("weui_uploader_input"); for (var i = 0; i < eles.length; i++) { if (!eles[i].Files){ eles[i].onchange = previewFile; } else{ if(eles[i].hasAttribute("data-scalewidth") || eles[i].hasAttribute("data-scaleheight")){ eles[i].onchange = previewFile3; } else {eles[i].onchange = previewFile2;} } }
document.addEventListener("plusready", function() { var webview = plus.webview.currentWebview(); plus.key.addEventListener(\'backbutton\', function() { webview.canBack(function(e) { if(e.canBack) { webview.back(); } else { plus.nativeUI.confirm("退出程序?", function(event) { if (event.index) { plus.runtime.quit(); } }, null, ["取消", "确定"]); //webview.close(); //hide,quit //plus.runtime.quit(); } }) }); }); }
|