SitePoint Sponsor

User Tag List

Results 1 to 16 of 16
  1. #1
    SitePoint Evangelist CyberFuture's Avatar
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting The GET Variable

    I have link like this:

    <a href="framer.htm?url=www.someplace.com">Click Here</a>

    In framer, I need to get the value of url and assign it to a JavaScript variable.

    Is this possible? If so, how?

  2. #2
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Something like:

    Code:
    var l = window.location;
    l.replace(/.+\?/, '');
    var a = l.split(/&/);
    for (o in a){
         var ar = o.split(/=/);
         eval (ar[0]+' = "'+ar[1]+'";');
         }
    I've not tested that - but i'd imagine it would
    turn the arguments in the url to variables for the script.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  3. #3
    SitePoint Evangelist CyberFuture's Avatar
    Join Date
    May 2001
    Location
    San Diego, CA
    Posts
    434
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, I'll give it a try on Monday.

    If anyone else has a solution, you're welcome to post.

  4. #4
    Currently Occupied; Till Sunda Andrew-J2000's Avatar
    Join Date
    Aug 2001
    Location
    London
    Posts
    2,475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    flawless i'm not sure why your using the long route, but what happened to the other location methods eg

    location.hash
    location.host
    location.hostname
    location.href
    location.pathname
    location.port
    location.protocol
    location.reload
    location.replace

    and finally the one you want

    location.search

    now wouldn't it be easier to search that string for the part you want to check?

  5. #5
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Depends on how you're doing it mate.

    Normally if i do pass variables at all i pass five at least.

    I prefer to have them all set as variables than having to call them through the location each time.

    Up to you though, i guess, and how many variables you may end up passing.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  6. #6
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, and I'm not 100% on this, but there is no public standard that applies to location.search, so that method may not be copasetic with all browsers.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  7. #7
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by beetle
    ....copasetic....
    Que?

    In addition, location.search is part of the W3C DOM Level 1 spec, and is supported by NS2+ and IE3+ !!!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  8. #8
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, sp error. Copacetic

    Sorry....I guess I was toting around some mis-information. (Not to be confused with Miss Information )
    Last edited by beetle; Aug 5, 2002 at 07:02.
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  9. #9
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol! Actually, "copasetic" is a valid spelling (see your link)! Just had never heard the word before and assumed it was a typo. Thanks for adding another obscure word to my vocabulary!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  10. #10
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Tsk tsk tsk I corrected myself and didn't even need too. NEED.....MORE.....COFFEE!!!

    Don't you remember that d*mn annoying song by Local H? "You know you just don't get it, keep it copasetic?" (apologies if I have now re-stuck this horrid little tune into your brain)
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  11. #11
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    * Feeds Marco's hunger *

    Anti-deinstitutionalisationsalism
    pneumonoultramicroscopicsiliconvolcanoconiosis


    The first one is a Gareth special - i hope to see it in dictionaries soon since anti-disestablishmentarialism is in there already.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  12. #12
    Web-coding NINJA! silver trophy beetle's Avatar
    Join Date
    Jul 2002
    Location
    Dallas, TX
    Posts
    2,900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooh! I know the 2nd one! It's some sort of disease....
    beetle a.k.a. Peter Bailey
    blogs: php | prophp | security | design | zen | software
    refs: dhtml | gecko | prototype | phpdocs | unicode | charsets
    tools: ide | ftp | regex | ffdev




  13. #13
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's a disease of the lungs caused by microscopic silicon particles in the air in close proximity to volcanic activity.

    The first one i used in a dissertation about Robert Lowell's incarceration for being a consciensious objector to the korean (?) war.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  14. #14
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The second one I knew already (and can reel off on demand).
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  15. #15
    Perl/Mason Guru Flawless_koder's Avatar
    Join Date
    Feb 2002
    Location
    Gatwick, UK
    Posts
    1,206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    .oO( oh what a laugh Marco must be down the pub )

    only j/king mate.

    Flawless
    ---=| If you're going to buy a pet - get a Shetland Giraffe |=---

  16. #16
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!


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
  •