dcsimg
www.webdeveloper.com
Results 1 to 6 of 6

Thread: Location.href is giving partial url

  1. #1
    Join Date
    Mar 2010
    Posts
    3

    Location.href is giving partial url

    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
    (it stops at the '&'

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

    I cannot change the URL as it is generated by my CMS.

    Thanks

    Henri

  2. #2
    Join Date
    Aug 2006
    Posts
    301
    yup, i think you have to use var myurl = urlencode(location.href), somethign to that effect, this will convert the & and ? into friendly characters

  3. #3
    Join Date
    Aug 2006
    Posts
    301

  4. #4
    Join Date
    Oct 2010
    Location
    Versailles, France
    Posts
    1,277
    The commas are not valid for the value mact ! You have probably to use a
    "http:mysite.com/index.php?mact"+encodeURIComponent("News,cntnt01,detail,0") for this value with special characters.

    NB : You have not to decode this value with PHP (See the Warning in the middle of on this page)
    Last edited by 007Julien; 06-21-2012 at 06:52 PM.

  5. #5
    Join Date
    Jan 2011
    Location
    United Kingdom, London
    Posts
    117
    location.href returns whole url, output it to console or just type in chrome/firebug console location.href you might have display problems if you attempt to display it unencoded since & might be interpreted as special char begining (i.e.   non breakable space)

  6. #6
    Join Date
    Aug 2006
    Posts
    301
    maurycy is correct, you can read all about the location object here. some of the characters in the url may be interpreted as html when you try to alert/write out the url to the screen, but it is all there.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles