宝塔服务器面板,一键全能部署及管理,送你10850元礼包,点我领取

php获取跳转前的url方法:1、获取URL带QUESTRING参数的JAVASCRIPT客户端方法;2、正则分析法,设置或获取整个URL为字符串,代码为【alertwindow.location.href)】。

php获取跳转前的url方法:

一:获取URL带QUESTRING参数的JAVASCRIPT客户端解决方案,相当于asp的request.querystring,PHP的$_GET

1.函数:

<Script language="javascript">
function GetRequest) {
var url = location.search; //获取duurl中"?"符后的字串
var theRequest = new Object);
if url.indexOf"?") !zhi= -1) {
var str = url.substr1);
strs = str.split"&");
forvar i = 0; i < strs.length; i ++) {
theRequest[strs[i].split"=")[0]]=strs[i].split"=")[1]);
}
}
return theRequest;
}
</Script>

2.然后通过调用此函数获取对应参数值:

<Script language="javascript">
var Request = new Object);
Request = GetRequest);
var 参数1,参数2,参数3,参数N;
参数1 = Request[''参数1''];
参数2 = Request[''参数2''];
参数3 = Request[''参数3''];
参数N = Request[''参数N''];
</Script>

以此获取url串中所带的同名参数

二、正则分析法。

function GetQueryStringname) {
var reg = new
RegExp"^|&)" + name +
"=[^&]*)&|$)","i");
var r =
window.location.search.substr1).matchreg);
if r!=null) return
r[2]); return null;
}
alertGetQueryString"参数名1"));
alertGetQueryString"参数名2"));
alertGetQueryString"参数名3"));

其他参数获取介绍:

//设置或获取对象指定的文件名或路径。

alertwindow.location.pathname);

//设置或获取整个 URL为字符串。

alertwindow.location.href);

//设置或获取与 URL关联的端口号码。

alertwindow.location.port);

//设置或获取 URL的协议部分。

alertwindow.location.protocol);

//设置或获取 href属性中在井号“#”后面的分段。

alertwindow.location.hash);

//设置或获取 location 或 URL 的hostname 和 port 号码。

alertwindow.location.host);

//设置或获取 href属性中跟在问号后面的部分。

alertwindow.location.search);

相关学习推荐:php编程(视频)