Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #22114

Re: Deriving state from the URL string...

Newsgroups comp.lang.javascript
Date 2013-11-21 18:31 -0800
References <l6m8es$qt7$1@speranza.aioe.org>
Message-ID <bd51c915-e228-4c3c-96ae-643d7aeb4d3d@googlegroups.com> (permalink)
Subject Re: Deriving state from the URL string...
From "Michael Haufe (TNO)" <tno@thenewobjective.com>

Show all headers | View raw


On Thursday, November 21, 2013 6:28:04 PM UTC-6, Chris M. Thomasson wrote:
> I was wondering what method to use for copying the URL and 
> 
> parse out number variables from said copy...
> 
> How good is`document.URL' in practice?

document.URL is DOM level 2, so all compatibility issues that implies. Perhaps (document|window).location is what you want?

A regex to get the params is pretty straightforward:

/^[^?#]+\?([^#]+)/i

example use on <http://example.com/?foo=1&bar=2&baz=3>

var re = /^[^?#]+\?([^#]+)/i,
    m = re.exec(document.location);

m[1]  // "foo=1&bar=2&baz=3"

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Deriving state from the URL string... "Chris M. Thomasson" <no@spam.invalid> - 2013-11-21 16:28 -0800
  Re: Deriving state from the URL string... "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2013-11-21 18:31 -0800
    Re: Deriving state from the URL string... "Chris M. Thomasson" <no@spam.invalid> - 2014-02-11 12:23 -0800

csiph-web