SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: URL characters

  1. #1
    SitePoint Member
    Join Date
    Jan 2003
    Location
    Australia
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    URL characters

    Hello,
    I was wondering if someone could help me to understand how when I try to parse and echo (sorry, I'm mainly php) a url like:
    http://yoursite.com/news/index.php?cat=3&paged=2
    it comes out as:
    http://yoursite.com/news/index.php?cat=3
    How can I get past the '&'?

    For example, I found this script while searching the forums:
    Code:
    <script type="text/javascript">
          function email()
          {
            var email = prompt("Email address?", "someone@domain.com");
            if(!email)
            {
              return false;
            }
            else
            {
              var href = "mailto:" + email;
              href += "?subject=Hello there";
              href += "&body=Take a look at this page: ";
              href += window.location.href;
              var link = document.getElementById("link1");
              link.href = href;
              return true;
            }
          }
        </script>
    Is there another variable that should be used to get it to get past '&'?

    Hope that makes sense and thanks in advance.

  2. #2
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, looks like my script...

    Try
    href += escape(window.location.href);


    (I think IE6 automatically replaces & with %26, but for other browsers you have to use escape())

  3. #3
    SitePoint Member
    Join Date
    Jan 2003
    Location
    Australia
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers Jofa,
    I'd gone through about 30 odd pages of search results, found your script in my travels but couldn't remember who's it was.

    Thanks again for the info, very helpful.


Bookmarks

Posting Permissions

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