Last active
August 29, 2015 14:13
-
-
Save gu-fan/f8dc838f6e5b4594f5e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // get a query object from query string | |
| function getQuery(str) { | |
| var q = {}; if (str == '') { return q }; try { str.substr(1).split("&").forEach(function(item) { q[item.split("=")[0]] = item.split("=")[1]}); } catch (err) { } finally { return q }; | |
| } | |
| // get a query string from a query object | |
| function setQuery(obj) { | |
| var s = ''; for (k in obj) { s += '&'+ k + '=' + obj[k] }; return s ; | |
| } | |
| function justifyQuery(url){ | |
| return url.replace(/[&?]{1,2}/, '?') | |
| } | |
| // Hooking the History page So that we can get the correct | |
| if (window.history) { | |
| var q = getQuery(location.search) | |
| if (q.hasOwnProperty('goto_status') ){ | |
| if (q.goto_status == 1 ) { | |
| location.replace(location.origin + '/inc/mall/my/myAddr') | |
| } | |
| delete q.goto_status | |
| var u=setQuery(q); | |
| u = u.replace(/[&?]{1,2}/, '?') | |
| window.history.replaceState({redirect:url } , '确认礼物', location.pathname + u ) | |
| } else if (q.hasOwnProperty('go')){ | |
| $.showTip('你已接受过该礼物') | |
| setTimeout(function(){ | |
| window.history.go(q.go) | |
| }, 0) | |
| } else { | |
| var url = (location.pathname + location.search + '&go=-1').replace(/[&?]{1,2}/,'?') | |
| window.history.replaceState({redirect:url } , '确认礼物', url) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment