/**//*
Get the value of the last parameter in the URL
*/
VaR STR = Window. Location. href;
// Alert (STR );
VaR es =/souceid = /;
Es.exe C (STR );
VaR right = Regexp. rightcontext;
// Alert (right );
// Column
<Script language = "JavaScript">
VaR STR = Window. Location. href;
VaR es =/souceid = /;
Es.exe C (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>
// The following describes how to write a function.
Function getparam (){
VaR url = Document. Location. href;
VaR name = ""
If (URL. indexof ("=")> 0)
{
Name = URL. substring (URL. indexof ("=") + 1, URL. length)
}
Return name;
}
/**//*
Obtains the specified URL parameter value.
URL: http://www.blogjava.net/blog? Name = BAINIAN
Parameter: paramname URL parameter
Call method: getparam ("name ")
Return Value: 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.?
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
}