0

On a page URL like :

http:mysite.com/index.php?mact=News,cntnt01,detail,0&cntnt01articleid=3&cntnt01returnid=15

Using location.href will return

http://mysite.com/index.php?mact=News,cntnt01,detail,0

is there a way to get the full URL including '...&cntnt01articleid=3&cntnt01returnid=15'

Thanks

Henri

  • If you don't have a JavaScript, get one now, and try inspecting `window.location` (i.e. `console.dir(window.location)`) – jsalonen Jun 18 '12 at 17:21
  • Please post your code. Regardless of validity of your URL, `location.href` does return the whole thing for me. – Ray Cheng Jun 18 '12 at 17:29
  • @jsalonen `If you don't have a JavaScript` ???????? :O – Alexandre Khoury Jun 18 '12 at 17:57
  • Really. I don't know what I thought when I wrote that o_O – jsalonen Jun 18 '12 at 18:20
  • @Ray The URLS are hereabove and the code is: – user1464314 Jun 18 '12 at 21:41
  • @user1464314, why are you assigning `mail_str` back to `location.href`? are you trying to force the default mail client to pop up and handle `email me`? if so, you just need to create an anchor link like I mentioned. – Ray Cheng Jun 18 '12 at 22:19

1 Answers1

2

If your URL was well-formatted then the querystring would be available in the window.location.href.

http://en.wikipedia.org/wiki/Percent-encoding

The comma is a reserved character in a URI and should not be used as a part of your querystring vales. Also, you should be URI-Encoding your url. This is done in javascript by calling encodeURI.

Related: Can I use commas in a URL?

Community
  • 1
  • 1
jbabey
  • 45,965
  • 12
  • 71
  • 94
  • Apparently (by me) window.location.href stops at the '&' sign. Unfortunately, this url is generated by a CMS and I cannot change it. – user1464314 Jun 18 '12 at 21:33
  • @user1464314 according to [MDN](https://developer.mozilla.org/en/DOM/window.location), `window.location.href` should give the entire URI, including querystring. – jbabey Jun 19 '12 at 12:55