php如何獲取跳轉(zhuǎn)前的url

發(fā)布時間:2024-02-23
php獲取跳轉(zhuǎn)前的url方法:1、獲取url帶questring參數(shù)的javascript客戶端方法;2、正則分析法,設(shè)置或獲取整個url為字符串,代碼為【alert(window.location.href)】。
php獲取跳轉(zhuǎn)前的url方法:
一:獲取url帶questring參數(shù)的javascript客戶端解決方案,相當(dāng)于asp的request.querystring,php的$_get
1.函數(shù):
<script language="javascript">function getrequest() {var url = location.search; //獲取duurl中"?"符后的字串var therequest = new object();if (url.indexof("?") !zhi= -1) {var str = url.substr(1);strs = str.split("&");for(var i = 0; i < strs.length; i ) {therequest[strs[i].split("=")[0]]=(strs[i].split("=")[1]);}}return therequest;}</script>2.然后通過調(diào)用此函數(shù)獲取對應(yīng)參數(shù)值:
<script language="javascript">var request = new object();request = getrequest();var 參數(shù)1,參數(shù)2,參數(shù)3,參數(shù)n;參數(shù)1 = request[''參數(shù)1''];參數(shù)2 = request[''參數(shù)2''];參數(shù)3 = request[''參數(shù)3''];參數(shù)n = request[''參數(shù)n''];</script>以此獲取url串中所帶的同名參數(shù)
二、正則分析法。
function getquerystring(name) {var reg = newregexp("(^|&)" name "=([^&]*)(&|$)","i");var r =window.location.search.substr(1).match(reg);if (r!=null) return(r[2]); return null;}alert(getquerystring("參數(shù)名1"));alert(getquerystring("參數(shù)名2"));alert(getquerystring("參數(shù)名3"));其他參數(shù)獲取介紹:
//設(shè)置或獲取對象指定的文件名或路徑。
alert(window.location.pathname);//設(shè)置或獲取整個 url為字符串。
alert(window.location.href);//設(shè)置或獲取與 url關(guān)聯(lián)的端口號碼。
alert(window.location.port);//設(shè)置或獲取 url的協(xié)議部分。
alert(window.location.protocol);//設(shè)置或獲取 href屬性中在井號“#”后面的分段。
alert(window.location.hash);//設(shè)置或獲取 location 或 url 的hostname 和 port 號碼。
alert(window.location.host);//設(shè)置或獲取 href屬性中跟在問號后面的部分。
alert(window.location.search);相關(guān)學(xué)習(xí)推薦:php編程(視頻)
上一個:滿足什么樣條件可以起訴離婚?
下一個:sgm3157_(umw(友臺半導(dǎo)體))sgm3157中文資料_價格_pdf手冊

花卉田間操作管理與病害防治
高產(chǎn)優(yōu)質(zhì)烏龍茶新品系紫龍袍選育
小米手環(huán)怎么取下來充電(小米手環(huán)怎么取下來充電視頻)
姜花枯萎病的危害與防治
朋友圈轉(zhuǎn)發(fā)分享音樂侵犯版權(quán)嗎
oppor17的參數(shù)是多少(oppor17的配置及參數(shù)表)
合同的效力狀態(tài)有幾種
維修德國kalinsky壓力表
YHXZB變頻串聯(lián)諧振試驗成套裝置的產(chǎn)品特點
高通驍龍cpu排行,手機高通驍龍cpu排行
十八禁 网站在线观看免费视频_2020av天堂网_一 级 黄 色 片免费网站_绝顶高潮合集Videos