|
-
Jun 22nd, 2001, 01:37 PM
#1
Thread Starter
Lively Member
VBscript to Javascript Translation
I still at the newbie stage as far as Javascript goes. How do you return a URL's Querystring using Javascript?
-
Jun 22nd, 2001, 02:01 PM
#2
Hey Nator.
I have the same question. Sorry I wish I could help. if you find Out could you e-mail me. I will do the same. [email protected]
Thanks
"B"
-
Jun 23rd, 2001, 12:03 AM
#3
Frenzied Member
Not certain if there is a built in function for it, but you could just put the URL into a string object and parse it for:
Code:
<html>
<head>
<title>Select the products...</title>
<meta name="Microsoft Theme" content="none">
<script language="JavaScript">
function SearchDemo()
{
var r, re, ln; //Declare variables.
var qs = new String('');
var s = new String(document.URL);
re = "[?]"; //Create regular expression pattern.
r = s.search(re); //Search the string.
if (r != -1)
{
ln = s.length;
qs = s.substring(r, ln);
}
return(qs); //Return the Boolean result.
}
function cmdDisplay_onclick()
{
window.alert(SearchDemo());
}
</script>
</head>
<body>
<input onclick="cmdDisplay_onclick()" type=button name=cmdDisplay value="ClickMe!">
</body>
</html>
If you copy this into a HTML document in your wwwroot folder for IIS and call it with a querystring, when you click on the button it will pop up a dialog with just the querystring. (You can't specify querystrings when calling a file locally.. at least I couldn't)
That should get you close..
oOOo--oOOo
__ /\/\onte96
oOOo--oOOo
Senior Programmer/Analyst
MCP
[email protected]
[email protected]
Your results may vary.. some restrictions may apply.. pricing and participation may vary.. not available in all states.. professional driver closed course..quantities limited..
-
Jun 23rd, 2001, 12:20 PM
#4
Fanatic Member
Use:
var myQuery;
myQuery = location.search;
This will return everthing from the "?" on. Then you can use the split() function to split the string on the "&"s, assuming that you have more than one value.
Chris
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|