Created
June 29, 2016 10:30
-
-
Save huobazi/959d38b1a488c1d0aa4fa44d2e2e7d2d to your computer and use it in GitHub Desktop.
Zepto or jQuery getUrlParam
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
$.fn.getUrlParam = function(j) { | |
var l = new RegExp("(^|&)" + j + "=([^&]*)(&|$)"); | |
var k = window.location.search.substr(1).match(l); | |
if (k != null) { | |
if (/^[\u4e00-\u9fa5]+$/.test(decodeURIComponent(k[2]))) { | |
return k[2]; | |
} else { | |
return $("<div/>").text(k[2]).html(); | |
} | |
} | |
return null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment