century
BlogJava
首頁(yè)
新隨筆
聯(lián)系
聚合
管理
隨筆-3 評(píng)論-26 文章-41 trackbacks-0
js獲取URL中的參數(shù)值
/**/
/*
獲取URL中最后一項(xiàng)參數(shù)的值
*/
var
str
=
window.location.href;
//
alert(str);
var
es
=/
SouceID
=/
;
es.exec(str);
var
right
=
RegExp.rightContext;
//
alert(right);
//列子
<script language="javascript">
var str=window.location.href;
var es=/SouceID=/;
es.exec(str);
var right=RegExp.rightContext;
//alert(right);
switch(right){
case 'Din':
case 'Exh':
case 'Banks':
case 'Shop':
case 'Treat':
case 'Trip':
ChgTab('tab3','tabcontent3');
break;
case 'Air':
case 'Railway':
case 'Road':
case 'Subway':
ChgTab('tab2','tabcontent2');
break;
default:
ChgTab('tab1','tabcontent1');
}
</script>
//
以下是函數(shù)的寫法
function
GetParam()
{
var
url
=
document.location.href;
var
name
=
""
if
(url.indexOf(
"
=
"
)
>
0
)
{
name
=
url.substring(url.indexOf(
"
=
"
)
+
1
,url.length)
}
return
name;
}
/**/
/*
獲取指定的URL參數(shù)值
URL:http://www.tkk7.com/blog?name=bainian
參數(shù):paramName URL參數(shù)
調(diào)用方法:getParam("name")
返回值:bainian
*/
//
1.
function
getParam(paramName)
{
paramValue
=
""
;
isFound
=
false
;
if
(
this
.location.search.indexOf(
"
?
"
)
==
0
&&
this
.location.search.indexOf(
"
=
"
)
>
1
)
{
arrSource
=
unescape(
this
.location.search).substring(
1
,
this
.location.search.length).split(
"
&
"
);
i
=
0
;
while
(i
<
arrSource.length
&&
!
isFound)
{
if
(arrSource[i].indexOf(
"
=
"
)
>
0
)
{
if
(arrSource[i].split(
"
=
"
)[
0
].toLowerCase()
==
paramName.toLowerCase())
{
paramValue
=
arrSource[i].split(
"
=
"
)[
1
];
isFound
=
true
;
}
}
i
++
;
}
}
return
paramValue;
}
//
2.
function
Request(sName)
{
/**/
/*
get last loc. of ?
right: find first loc. of sName
+2
retrieve value before next &
*/
var
sURL
=
new
String(window.location);
var
sURL
=
document.location.href;
var
iQMark
=
sURL.lastIndexOf('
?
');
var
iLensName
=
sName.length;
//
retrieve loc. of sName
var
iStart
=
sURL.indexOf('
?
'
+
sName
+
'
=
')
//
limitation 1
if
(iStart
==-
1
)
{
//
not found at start
iStart
=
sURL.indexOf('
&
'
+
sName
+
'
=
')
//
limitation 1
if
(iStart
==-
1
)
{
//
not found at end
return
0
;
//
not found
}
}
iStart
=
iStart
+
+
iLensName
+
2
;
var
iTemp
=
sURL.indexOf('
&
',iStart);
//
next pair start
if
(iTemp
==-
1
)
{
//
EOF
iTemp
=
sURL.length;
}
return
sURL.slice(iStart,iTemp ) ;
sURL
=
null
;
//
destroy String
}
posted on 2008-03-12 12:53
百年
閱讀(37321)
評(píng)論(5)
編輯
收藏
所屬分類:
Javascript Article
評(píng)論:
#
re: js獲取URL中的參數(shù)值[未登錄] 2012-10-09 23:04 |
lee
獲取url中的參數(shù)值
回復(fù)
更多評(píng)論
#
re: js獲取URL中的參數(shù)值[未登錄] 2013-02-09 08:43 |
匿名
感謝分享.
回復(fù)
更多評(píng)論
#
re: js獲取URL中的參數(shù)值 2013-08-06 10:58 |
afasfas
feafwaefeawfewaef
回復(fù)
更多評(píng)論
#
re: js獲取URL中的參數(shù)值 2013-08-06 10:58 |
afasfas
@afasfas
@afasfas
回復(fù)
更多評(píng)論
#
re: js獲取URL中的參數(shù)值
2014-08-26 14:11 |
趙元春
網(wǎng)址打不開
回復(fù)
更多評(píng)論
新用戶注冊(cè)
刷新評(píng)論列表
只有注冊(cè)用戶
登錄
后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關(guān)文章:
單擊放回上頁(yè)的按鈕或使用window.history.go(-1)返回上頁(yè)的同時(shí)刷新"上頁(yè)"技術(shù)
js 提交表單
ShowModalDialog方法的參數(shù)傳遞
js獲取URL中的參數(shù)值
計(jì)算中英文混合字符串長(zhǎng)度js函數(shù)
window.open和window.showModalDialog的用法詳細(xì)說明
常用于表單JS驗(yàn)證
IE與FireFox下用程序觸發(fā)鼠標(biāo)點(diǎn)擊事件不同的實(shí)現(xiàn)
Javascript中LenB的計(jì)算(ASP)
Javascript 實(shí)現(xiàn)的排序
<
2012年10月
>
日
一
二
三
四
五
六
30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
常用鏈接
我的隨筆
我的評(píng)論
我的參與
最新評(píng)論
留言簿
(1)
給我留言
查看公開留言
查看私人留言
隨筆檔案
2008年7月 (2)
2006年8月 (1)
文章分類
.net(6)
Asp Article(14)
computer manage(2)
div+css(2)
Flash+XML/XML+Flash
Java Article(2)
Javascript Article(10)
Jsp Article(4)
Others(1)
文章檔案
2008年11月 (1)
2008年9月 (3)
2008年8月 (1)
2008年7月 (1)
2008年6月 (1)
2008年4月 (2)
2008年3月 (2)
2008年1月 (2)
2007年12月 (2)
2007年11月 (6)
2007年10月 (1)
2007年8月 (2)
2007年7月 (1)
2007年4月 (3)
2007年3月 (4)
2006年8月 (2)
2006年7月 (1)
2006年6月 (4)
相冊(cè)
My collection
收藏夾
JAVA程序員面試32問
CSS
ASP導(dǎo)出Excel數(shù)據(jù)的四種方法
CSS
Jsp
tomcat set
無憂視窗:51windows
用AspJpeg調(diào)整文字水印透明,生成圖片水印的效果
Draw dynamicdrive
Draw dynamic photo
My photo is very poor,so i must word hard!
Draw Flash
Draw Flash
Fade
Fade Images in photoshop
Flash+XML
Flash+XML
http://www.flashcom.com.cn/bbs/forumdisplay.php?f=3
Jacob
jacob
Search Website
程序員代碼搜索
Krugle - Code Search for Developers
Struts
Struts中用動(dòng)態(tài)選擇的元素創(chuàng)建復(fù)選框
include some website design...
Studying English
Online Dictionary
Here,it is me study english
Translate on google
study
Text Link
\\Access Sql腳本編寫器!
Access to Sql 腳本編寫器
搜索
最新評(píng)論
1.?re: js獲取URL中的參數(shù)值
網(wǎng)址打不開
--趙元春
2.?re: js獲取URL中的參數(shù)值
feafwaefeawfewaef
--afasfas
3.?re: js獲取URL中的參數(shù)值
@afasfas
@afasfas
--afasfas
4.?re: js獲取URL中的參數(shù)值[未登錄]
感謝分享.
--匿名
5.?re: js獲取URL中的參數(shù)值[未登錄]
獲取url中的參數(shù)值
--lee
閱讀排行榜
1.?SP-service provider(344)
2.?為了學(xué)英語,轉(zhuǎn)載功夫熊貓一篇(280)
3.?什么是軟件外包?(260)
評(píng)論排行榜
1.?為了學(xué)英語,轉(zhuǎn)載功夫熊貓一篇(0)
2.?SP-service provider(0)
3.?什么是軟件外包?(0)
Powered by:
博客園
模板提供:
滬江博客
Copyright ©2025 百年
主站蜘蛛池模板:
91亚洲性爱在线视频
|
99亚洲精品高清一二区
|
精品福利一区二区三区免费视频
|
国产日韩久久免费影院
|
亚洲精品久久无码
|
免费国产a国产片高清
|
四虎精品视频在线永久免费观看
|
一区二区免费在线观看
|
亚洲av中文无码乱人伦在线咪咕
|
日本高清免费网站
|
91免费国产视频
|
美女扒开尿口给男人爽免费视频
|
亚洲产国偷V产偷V自拍色戒
|
四虎精品亚洲一区二区三区
|
免费国产成人午夜在线观看
|
美女羞羞免费视频网站
|
亚洲女子高潮不断爆白浆
|
亚洲精品亚洲人成在线麻豆
|
亚洲爆乳精品无码一区二区三区
|
亚洲福利中文字幕在线网址
|
天天摸天天操免费播放小视频
|
伊人久久国产免费观看视频
|
国产精品成人亚洲
|
亚洲国产精品无码久久久秋霞1
|
亚洲人成在线精品
|
亚洲男人天堂影院
|
亚洲视频一区在线播放
|
久久久久亚洲AV无码麻豆
|
亚洲精品成人av在线
|
免费中文字幕不卡视频
|
国产一卡二卡≡卡四卡免费乱码
|
女同免费毛片在线播放
|
亚洲小说图片视频
|
亚洲成人黄色网址
|
亚洲人成777在线播放
|
亚洲人配人种jizz
|
国产精品高清视亚洲精品
|
中文字幕亚洲情99在线
|
亚洲国产欧美国产综合一区
|
性色av极品无码专区亚洲
|
国产亚洲精品国产福利在线观看
|