home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 2000 April
/
VPR0004B.BIN
/
DRIVER
/
COMPAQ
/
SP12255
/
sp12255.exe
/
DMWEBC1.CAB
/
PARSEARG.JS
< prev
next >
Wrap
Text File
|
1999-01-18
|
2KB
|
76 lines
// $Id: PARSEARG.JS 1.1 1998/01/22 20:13:29 cboeker Q/A $
// Copyright (C) 1998 Compaq Computer Corporation
pageArgs = new Array;
function argPair(nameIn, valueIn)
{
this.name = nameIn;
this.value = valueIn;
}
function mySplit(stringIn, splitOn)
{
tempString = new String(stringIn);
splitString = new String(splitOn);
rc = new Array;
rcIndex = 0;
startIndex = 0;
splitIndex = 0;
while(-1 != (splitIndex = tempString.indexOf( splitOn, startIndex )))
{
rc[rcIndex++] = tempString.substring( startIndex, splitIndex );
startIndex = splitIndex + splitString.length;
}
// process the final split (or lack thereof)
rc[rcIndex] = tempString.substring( startIndex, tempString.length);
return rc;
}
function parseArgs()
{
if( null == location.search )
return;
args = location.search.substring(1);
// now split off each pair marked by &
argPairs = mySplit( args, "&");
argIndex = 0;
// split the pairs on the first =
for(i=0; i < argPairs.length; i++)
{
equalsIndex = argPairs[i].indexOf("=");
if(-1 != equalsIndex)
{
pairName = argPairs[i].substring( 0, equalsIndex );
pairValue = argPairs[i].substring( equalsIndex+1, argPairs[i].length );
pageArgs[argIndex++] = new argPair( pairName, pairValue );
}
}
}
function findArg( argName )
{
for(i=0; i<pageArgs.length; i++)
{
if(pageArgs[i].name == argName)
{
return pageArgs[i].value;
}
}
return -1;
}
parseArgs();