Toggle navigation
VA伐木累
社区
VA伐木累
Proxy
JSON
BASE64
MyGit
登录
注册
×
登录
邮箱
密码
忘记密码?
置顶
微信公众号返回键动作实现(也适用于PC端)
•发布于
•作者
liuzy
•2912 次浏览
•最后一次编辑是
•来自
资讯
```js /* ********** 浏览器返回按钮实现 ********** */ var anchor = ''; // 当前锚 window.addEventListener('popstate', function(e) { // 点击返回时执行 if (!anchor.endsWith('#win1')) { win_close(anchor.slice(-4)); } else { if ($('.mo-msg').hasClass("exiting") || (navigator.userAgent && !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/))) { wx.closeWindow(); } else { showMsg('请再按一次退出'); $('.mo-msg').addClass("exiting"); window.history.pushState({ title: '', url: '#win1' }, '', '#win1'); } } }, false); function append_anchor(win) { // 加锚 if (window.history.pushState && !anchor.endsWith(win)) { var url = win == '#win1' ? win : window.history.state && window.history.state.url ? window.history.state.url + win : win; window.history.pushState({ title: '', url: url }, '', url); anchor = url; } } function remove_anchor(win) { // 减锚 if (window.history.replaceState && anchor.endsWith(win)) { var url = anchor.slice(0, -5); window.history.replaceState({ title: '', url: url }, '', url); anchor = url; } } /* ********** 层级窗口 ********** */ var win_closed = {}; function win_close(win) { console.log(win + ' close'); remove_anchor('#' + win); $('#' + win).removeClass('open'); if (win_closed[win]) { win_closed[win](); win_closed[win] = null; } setTimeout(function() { $('#' + win + '-midd').html(''); }, 500); } var win_xhr = {}; var win_scroll = {}; function win_open(win, url) { console.log(win + ' load ' + url); if (win == 'win1') { showLoading(); $('.main_menu').each(function() { if ($(this).data('url') == url && !$(this).hasClass('active')) { $(this).addClass("active").siblings().removeClass("active"); return; } }); Storage.set('last_page', url); } append_anchor('#' + win); $('#' + win).addClass('open'); win_xhr[win] && win_xhr[win].abort(); $('#' + win + '-midd').load(win + '/' + url, function(res, stat, xhr) { win_xhr[win] = xhr; if (win == 'win1') { hideLoading(); } else if (win == 'win5' || win == 'win6' || win == 'win7') { win_scroll[win] = new IScroll('#wrapper' + win.slice(-1), { probeType: 3, mouseWheel: true, click: true, bindToWrapper: true }); } }); } ```
1 回复
duke147
这个有不对外开放的权限吗? 有时候写博客,没写完,不想往下写了,只对自己开放那种。
作者
liuzy
积分: 841
“ 黑眼圈圈男 ”
无人回复话题
SonarQube 9.4 + PostgreSQL
shell倒计时
日常网络巧技
使用ssh创建socks5代理服务
NodeJS集群demo
作者其他话题
SonarQube 9.4 + PostgreSQL
shell倒计时
日常网络巧技
使用ssh创建socks5代理服务
NodeJS集群demo
回到顶部
友情链接:
JFinal
©2015 Powered by
jfinalbbs
沪ICP备15012258号