Skip to content

Instantly share code, notes, and snippets.

@QETHAN
Created April 28, 2013 04:54
Show Gist options
  • Save QETHAN/5475943 to your computer and use it in GitHub Desktop.
Save QETHAN/5475943 to your computer and use it in GitHub Desktop.
/**
* URL地址后面增加随机参数
*/
define(function(require, exports, module) {
exports.queryRandom = function(url) {
var strQueryRandom = "random=" + Math.random();
var arrQuery = url.split("?");
if (arrQuery[1] != undefined) {
// 含查询字符串
if (url.slice(-1) === "&") {
url = url + strQueryRandom;
} else {
url = url + "&" + strQueryRandom;
}
} else {
// 不含查询字符串
url = url + "?" + strQueryRandom;
}
return url;
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment