Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using location.search object.

Status
Not open for further replies.

awolff01

Programmer
Jun 17, 2003
55
0
0
US
Hello,

I would like to determine the query string of the current window.

I was looking at some example in the Rhino book that used the following syntax:

var qs = location.search.substring(1);
alert(qs);

When I use the above syntax in my script I do not see anything. But my url has alot of stuff after the "?"

I am not sure I undertand what the .substring(1) portion is doing?

Any help is appreciated.
 
string.substring(from,to)
string.substr(start,length)

They are not the same...

Does this help?

var qs = location.search.substr(1);
alert(qs);


If not, try it without the substring...

var qs = location.search
alert(qs);


Programming today is a race between software engineers striving to build better and bigger idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning. - Rick Cook (No, I'm not Rick)

zen.gif
 
the substring(1) is to remove the "?" at the beginning.

are you using frames? if so you might need to use

var qs = top.location.search.substring(1);
alert(qs);


=========================================================
-jeff
try { succeed(); } catch(E) { tryAgain(); }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top