[Javascript] Extracting data from current URL

Colin Cochrane colin at vfs.com
Wed May 23 10:49:35 CDT 2001


> order to discover their username?

Sure. Try this: (NB: I just tucked your location value into a string,
you'll have to grab this as well, but that's pretty straight-forward.)

__Code__

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">

<html><head><title>pulling out info</title>
<script language="javascript" type="text/javascript">

<!-- hide

function getit() {
	var url =
"http://servername/servlet/WebClient/main?user=stevehearne&pass=mypassword&serve
r=127.0.0.1" ;
	var end = url.length;
	var grabname=url.substring(41,end);

	var stuff = grabname.split("&");

	for (var i = 0; i<stuff.length;i++) {
		alert(stuff[i]);
	}
}
// done -->

</script>
</head>

<body onLoad="getit();">

__EndCode__

cdc

########################################################

When provided for in advance, these disorders can be cured; but if you wait
until they are upon you, medicine is too late--the disease has become
incurable.
				--Niccolo Machiavelli, The Prince

Colin Cochrane
Head Instructor
VFS New Media
http://www.vfs.com/~colin/

########################################################






More information about the Javascript mailing list