location.search

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

location.search

Post by newmember »

i use this line in my js script:

location.search = location.search + "?cs=1"

but this doesn't work...i used alert() to print location.search before and after and it doesn't change... :?

so can i use this line or location.search is read-only ?

P.S.
also question about match() function.... i found out it return array of 3 element. first cell is the matched string, end other two cells contains first and last chracters of matched string...
Is this function supposed to return an array?? none of the examples/references i saw, mention that match() return array
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

If it works by placing the result in a new var...then place it in a new var.
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

Post by newmember »

i need to save result in location.search.
i want to use it for saving state of menu (which part are closed/hidden and which opened/visible) when i browse away of the page...
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

yes, I believe location.search is read only. you can alter location.href to actually change the location though.

you can save the state of the menu in your php scripts by storing it into a session variable. It's a lot easier, and safer because Javascript could easily be off.
User avatar
newmember
Forum Contributor
Posts: 252
Joined: Fri Apr 02, 2004 12:36 pm

Post by newmember »

this site:
http://www.w3schools.com/htmldom/dom_obj_location.asp
says about "location.search":
Sets or returns the part of the href property that follows the question mark (?)
Post Reply