Forum Moderators: open

Message Too Old, No Replies

how to get a var from url

value of 'what' in page.htm?what=soup

         

carsten888

6:58 pm on Feb 3, 2006 (gmt 0)

10+ Year Member



How to get a value of a variable from a url?

var url;
url = location.href;

url is then only the string without the variable 'what'.
if it would return the complete url I could substring things.

anyone?

DrDoc

7:05 pm on Feb 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I guess I don't really get what you are saying. From the thread title I deduce one thing, but from your post another. :)

location.href
by default returns the entire URL, including the query string (if any).
To directly access the query string, however, use
location.search

Bernard Marx

8:36 pm on Feb 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Agreed. A little bit confusing.
The meat is in the subtitle though.

Did this yesterday:
[webmasterworld.com...]
(post #2)

carsten888

7:41 am on Feb 4, 2006 (gmt 0)

10+ Year Member



thanks.

I did not realize my question was so difficult to understand.

I couldn't get it to work because I only later realized The page was in a frameset and the url within the frameset did not have those vars. sorry about that. thanks for that great function!