how can I capture data from a url?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • andersond
    New Member
    • Feb 2007
    • 110

    how can I capture data from a url?

    If I use a URL to open a webbrowser and go to a website how can I capture the data I have included in the URL?

    Example:
    Code:
     https://www.yatayatayata.com?codenumber=2241w
    What html or javascript code can I use to capture the "codenumber=224 1w?
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    try location.search.

    Comment

    • andersond
      New Member
      • Feb 2007
      • 110

      #3
      In other words, using the url above if I am writing the website that resides at "https://www.yatayatayat a.com" and I enter "location.searc h" for the value of an input of type "text" it will resolve to "?codenumber=22 41w"? I really don't think you're addressing the question I am asking. I want to know how to capture "2241w" as the value of a variable called "codenumber " in a web page that resides at "https://www.yatayatayat a.com." If that is what you are telling me, then it doesn't work. In my web page I entered:
      Code:
      <input type="text" name="QuoteNum" size="20" value="javascript:document.location.search;">
      and it resolved to "document.locat ion.search".

      Is that the question you meant to answer?

      I want to know how to capture (in the web page that is called up) the value of a variable I used in the URL that I used to call the web page. How can I do that?

      Comment

      • andersond
        New Member
        • Feb 2007
        • 110

        #4
        ...and I tried it with and without the "javascript " and with and without the "document"

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #5
          your question:
          What html or javascript code can I use to capture the "codenumber=224 1w?
          as you have figured out window.location .search gives you "?codenumber=22 41w". I assume you are able to remove the ? yourself.

          question answered.

          EDIT: after repeatedly re-reading all your posts, I come to the conclusion, that you mean "capture 2241w" (which was IMHO not obvious in the first post). It might come to mind that this is the remaining string after the =, which could be easily located through String.indexOf( ). Do I need to say more?

          as for the HTML interaction, JavaScript in HTML can be executed by
          - Event Listeners ( elem.addEventLi stener("event", callback, bool_useCapture ); )
          - Event Attributes ( <elem onclick="// JavaScript code goes here"> )
          - links ( <a href="javascrip t: // code goes here"> )
          Last edited by Dormilich; Jan 19 '10, 10:57 PM. Reason: finding the REAL question

          Comment

          • andersond
            New Member
            • Feb 2007
            • 110

            #6
            Thank you for your help and you patients

            Comment

            Working...