Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts

    :: need to grab some info from the url - how? ::

    ok so ive built a search engine in lotus notes (booooo hiss blumin boss and his notes servers) anyway the url for searching is like this:

    http://wwwnotesint/IT/DEVELOPMENT/li...ry=SEARCHWORDS IN HERE&SearchFuzzy=1 (obviously the spaces are converted to % 2 0)

    now, i want a script that pulls the info from the address bar and document.writes it somewhere - how can i do this? bearing in mind im not very good at javascript

    thanks!
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    oops - the url has been mutated

    ok this is the url :

    host/IT/DEVELOPMENT/searchtest.nsf/Search?SearchView&Query=SEARCHWORDS IN HERE&SearchFuzzy=1

    how can i strip the bit b4 the = and after the &?

    thanks all!
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    ok i found a way to do it:

    Code:
    <script language="JavaScript" type="text/javascript">
    
    if (document.location.href != 'http://www.simonsgroup.com/IT/DEVELOPMENT/liam.nsf/Search?SearchView&Query=aaaaaaaaa&SearchFuzzy=1') {
    var searchurl = document.location.href;
    var compact1 = searchurl.split('http://www.simonsgroup.com/IT/DEVELOPMENT/liam.nsf/Search?SearchView&Query=');
    var compact2 = compact1[1].split('&SearchFuzzy=1');
    //document.write(compact2[0]);
    var output = compact2[0].split("%20").join(" ");
    document.write(output);
    }
    </script>
    i am slowly picking this js up i think
    btw is there a better way to do the above or will i have problems anywhere?
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    btw the aaaaaaaaaa bit is the way i link to the page in the 1st place - blumin notes suck more than elton john
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson

  • #5
    New Coder
    Join Date
    Jun 2002
    Location
    yorkshire, uk
    Posts
    65
    Thanks
    0
    Thanked 0 Times in 0 Posts
    babel,

    looks like you worked it out while i was writing this. here's my idea.

    searchString = location.search.split("=")[1].split("&")[0]

    location.search is everything from and including the ? in the URL:
    "?SearchView&Query=SEARCHWORDS IN HERE&SearchFuzzy=1"

    .split("=") returns an array of all the substrings separated by the = character:
    "?SearchView&Query",
    "SEARCHWORDS IN HERE&SearchFuzzy",
    "1"

    [1] returns the second item from this array:
    "SEARCHWORDS IN HERE&SearchFuzzy"

    .split("&") returns an array of all the substrings separated by the & character:
    "SEARCHWORDS IN HERE",
    "SearchFuzzy"

    [0] returns the first item from this array:
    "SEARCHWORDS IN HERE"

    this ok? of course, this only works for this example, if the SearchView param was missing or if the SearchFuzzy param was put in front of the Query param, you'd get some other value.
    if you want to sort out these situations, you can write a more complex script that splits the location.search into items separated by "&" and then eval()s each one of them, making the URL params into variables directly.

    Last edited by neil.c; 07-23-2002 at 05:01 PM.
    neil.c

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Location
    USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Location
    England =)
    Posts
    523
    Thanks
    26
    Thanked 0 Times in 0 Posts
    thanks guys!
    "They hired me for my motivational skills. Everyone at work says they have to work much harder when I`m around" Homer J Simpson


  •  

    Posting Permissions

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