asp.net, 当打开网站是 给url增加一个参数,怎么写
例如 网址 http://www.aa.com/default.aspx
改成 http://www.aa.com/default.aspx?a=1
function addUrlPara(name, value) {
var currentUrl = window.location.href.split('#')[0];
if (/\?/g.test(currentUrl)) {
if (/name=[-\w]{4,25}/g.test(currentUrl)) {
currentUrl = currentUrl.replace(/name=[-\w]{4,25}/g, name + "=" + value);
} else {
currentUrl += "&" + name + "=" + value;
}
} else {
currentUrl += "?" + name + "=" + value;
}
if (window.location.href.split('#')[1]) {
window.location.href = currentUrl + '#' + window.location.href.split('#')[1];
} else {
window.location.href = currentUrl;
}
}
写在 global里怎么写
打开网址?你怎么打开的。。如果是直接浏览器输入的是无法添加的,只能服务器端判断如果是某种地址,然后再跳转
比如 别人打开我的网站 http://www.aa.com/default.aspx
自动变成 http://www.aa.com/default.aspx?date=20160826
你的页面http://www.aa.com/default.aspx 中有一个表单或者超链接,用户点击后会自动向服务器发送GET请求,获取 http://www.aa.com/default.aspx?date=20160826
用户打开我的网站,自动在链接上加一个参数