function getUrlParameter(name) {
/// <summary>获得URL的指字参数</summary>
/// <param name="name" type="String">参数名</param>
var url = location.href;
var index = url.indexOf("?");
var result = "null";
if (index > 0) {
var items = url.substring(index + 1).match(new RegExp("[^&]+", "g"));
for (var j = 0; j < items.length; j++) {
if (new RegExp(name + "=", "g").test(items[j])) {
result = items[j].replace(new RegExp(name + "=", "g"), "");
}
}
}
return result;
}
function getCookies(name, sub_name) {
/// <summary>获得cookie集合值[健值对]</summary>
/// <param name="name" type="String">cookie名称</param>
/// <param name="sub_name" type="String">找到cookie集合值中sub_name健的值</param>
var result;
var reg = /[^;]+/ig;
var itmes = document.cookie.match(new RegExp("[^;]+", "ig"));
for (var i = 0; i < itmes.length; i++) {
var cookie_name = itmes[i].substring(0, itmes[i].indexOf("="));
cookie_name = cookie_name.replace(/ /g, "");
if (cookie_name == name) {
var subItmes = itmes[i].substring(itmes[i].indexOf("=") + 1).match(new RegExp("[^&]+", "g"));
for (var j = 0; j < subItmes.length; j++) {
if (new RegExp(sub_name + "=", "g").test(subItmes[j])) {
result = subItmes[j].replace(new RegExp(sub_name + "=", "g"), "");
}
}
}
}
return result;
}
function createValidateString(data) {
/// <summary>制作中文验证码</summary>
/// <param name="data" type="json">{id,name}id要显示的元素标签,name验证码存放在cookie里的名称</param>
var strings = ['五福临门', '福如东海', '步步高升', '岁岁平安', '辞旧迎新', '心想事成', '事事顺心', '年年平安', '十全十美', '事业有成', '蒸蒸日上', '四季发财', '扬帆远航', '一生平安', '身体健康', '马到成功', '九九九', '恭喜发财', '财源滚滚', '招财进宝', '财源广进'];
var index = parseInt(Math.random() * 20);
document.getElementById(data.id).innerHTML = strings[index];
setCookie(data.name, strings[index]);
}
function checkBoxSelect() {
/// <summary>CheckBox实现全选操作</summary>
var items = document.getElementsByTagName("input");
if (items.length > 0) {
for (var i = 0; i < items.length; i++) {
if (items[i].type == "checkbox") {
if (items[i].checked == true) {
items[i].checked = false;
} else {
items[i].checked = true;
}
}
}
}
}
function btnUrl(name, url) {
/// <summary>按钮跳转到指定的路径</summary>
/// <param name="name" type="String">参数名</param>
/// <param name="url" type="String">指定的路径</param>
var val = getUrlParameter(name);
location = url + "?" + name + "=" + val;
}