We know that on the server side ASP, JSP, etc.ProgramParameters sent from form on the HTML page can be accepted. So, can we pass parameters to the HTML page. Yes.
Principle: parameters are obtained using the delimiter in window. Location. href.
Method 1:
/*
* Function: obtain parameters from href.
* Shref: http://www.cscenter.com.cn/arg.htm? Arg1 = D & arg2 = Re
* Sargname: arg1, arg2
* Return: the value of Arg. D, re
*/
Function Getargsfromhref (shref, sargname)
{
VaR ARGs = Shref. Split ( " ? " );
VaR Retval = "" ;
If (ARGs [ 0 ] = Shref) /* The parameter is null. */
{
Return Retval; /* No action required */
}
VaR Str = ARGs [ 1 ];
ARGs = Str. Split ( " & " );
For ( VaR I = 0 ; I < Args. length; I ++ )
{
Str = ARGs [I];
VaR ARG = Str. Split ( " = " );
If (Arg. Length <= 1 ) Continue ;
If (ARG [ 0 ] = Sargname) retval = Arg [ 1 ];
}
Return Retval;
}
Method 2: Function Getvalue (name)
{
VaR Str = Window. Location. search;
If (Str. indexof (name) ! =- 1 )
{
VaR Pos_start = Str. indexof (name) + Name. Length + 1 ;
VaR Pos_end = Str. indexof ( " & " , Pos_start );
If (Pos_end =- 1 )
{
Return Str. substring (pos_start );
}
Else
{
Return Str. substring (pos_start, pos_end)
}
}
Else
{
Return " No such name value " ;
}
}
Alert (getvalue (name ));
Method 3:
Request = {
Querystring: Function (Item ){
VaR Svalue = Location. Search. Match ( New Regexp ( " [\? \ &] " + Item + " = ([^ \ &] *) (\ &?) " , " I " ));
Return Svalue ? Svalue [ 1 ]: Svalue;
}
}
Alert (request. querystring ( " ID " ));
Method 4: VaR URL = Location. search;
VaR Request = New Object ();
If (URL. indexof ( " ? " ) ! =- 1 )
{
VaR Str = URL. substr ( 1 ); // Remove? No.
STRs = Str. tolowercase ();
STRs = STRs. Split ( " & " );
For ( VaR I = 0 ; I < STRs. length; I ++ )
{
Request [STRs [I]. Split ( " = " )[ 0 ] = Unescape (STRs [I]. Split ( " = " )[ 1 ]);
}
}
VaRMapwidth=Request ["W"];
VaRMapheight=Request ["H"];