Go Back   SitePoint Forums > Forum Index > Program Your Site > JavaScript
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Sep 9, 2003, 13:17   #1
Jeff Lange
"Of" != "Have"
bronze trophy
 
Jeff Lange's Avatar
 
Join Date: Jan 2003
Location: Calgary, Canada
Posts: 2,060
getting GET variables from the url on a page

Code:
var uriString = window.location.href;
var getVars = new Array();
if (-1 != (quePos = uriString.indexOf('?')))
{
 uriString = uriString.substr(quePos + 1);
 uriString = uriString.split(/&/);
 for (var i in uriString)
 {
  var currentVar = uriString[i];
  var equalPos = currentVar.indexOf('=');
  equalPos = equalPos==-1 ? currentVar.length : equalPos;
  var currentVal = currentVar.substr(equalPos + 1);
  currentVar = currentVar.substr(0, equalPos);
  getVars[currentVar] = unescape(currentVal);
 }
}
Hope it helps someone
Jeff Lange is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 19:06.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved