正确写法<script> 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 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 } }
正确写法<script> 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 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 } }
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 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
}
document.write('<script src="b.asp?CurrPage='+Request("url")+'"></s'+'cript>')
</script>
b.asp
<%
Response.write "alert('" & Request("CurrPage") & "')"
%>
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 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
}
document.write('<script src="b.asp?CurrPage='+Request("url")+'"></s'+'cript>')
</script>
b.asp
<%
Response.write "alert('" & Request("CurrPage") & "')"
%>