Results 1 to 5 of 5

Thread: How do get URL when URL content #

  1. #1
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do get URL when URL content #


  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    To send a variable/value through the url, it is standard to use ?var=value, not #var,value. This is mostly used with PHP (and asp, etc, I think), but can be accessed from javascript as well.
    Not sure about your current situation as I usually use php.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  3. #3
    Join Date
    Aug 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I'm using Ajax + PHP so url content #
    At url : http://www.myweb.com/music/index.php#Music,18
    I listen a song (ex: I love you). After I copy url (http://www.myweb.com/music/index.php#Music,18) and send for my friend. I want my friend listen that song (ex: I love you) too

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by tonynguyen1080 View Post
    I'm using Ajax + PHP so url content #
    One does not imply the other. A fragment identifier is not appropriate based upon your description.

    The fragment component identifies a secondary resource by reference to the primary resource identified by the preceding portions of the URI. In this context, a secondary resource is a portion or subset of the primary, or a particular view of it. What that means, exactly, depends on the media type of the resource.

    For the familiar case of HTML, the fragment identifies a location within the document - a matching id attribute value, or some matching name attribute values[1] - and the user agent will move to that location once the document has loaded.

    For other media types, the fragment component is nonsensical. It has no meaning for a PHP script as the fragment is not sent in requests and the result of server-side PHP is some other content type.

    At url : http://www.myweb.com/music/index.php#Music,18
    I listen a song (ex: I love you). After I copy url (http://www.myweb.com/music/index.php#Music,18) and send for my friend. I want my friend listen that song (ex: I love you) too
    As djr33 suggested, use the query fragment to transfer the data. Change the format slightly to something like /music/index.php?song=18. If the PHP script is interested in this, the data can be retrieved from $_GET['song']. If client-side code is the intended user, then the information can be parsed from the document.URL property.

    Mike


    [1] Not all name attributes act as identifiers, such as with form controls. In that case, it is the control name used during form submission.

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    The only advantage I can see over ? with # is that it doesn't reload the page when clicked (at least if implemented as a target/anchor setup). However, if this is the case and you are loading it live with ajax/js, then you might as well just use onclick="songname='value';" or something... no need to bother going through the URL.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

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
  •