SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Mar 2004
    Location
    Bath
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript querystring query?

    I am sending the following query to my Atomz search page;

    http://search.atomz.com/search/?sp-q=searchterm&style=style3&sp-a=sp10029b17&sp-p=all&sp-f=ISO-8859-1

    I am trying to put together some javascript that picks out the style value from this and writes it to the HTML file as the name of the current stylesheet.......can anybody help me?

    Thanx
    Last edited by kevin_o_malley; Mar 11, 2004 at 02:26.

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2004
    Location
    Third Stone From The Sun
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    window.location.search

    It won't parse the individual params, but it's a start.
    My outdated site is down for a while now.

  3. #3
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Garrett...love the redesign.

    kevin...not sure what 'writes it to the HTML file as the name of the current stylesheet' means - did you want to dynamically output the href of the .css file, or use a stylesheet switcher to load the correct one? Anyway:
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" 
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    <head>
    <title>untitled</title>
    </head>
    <body>
    <script type="text/javascript">
    
    var Qstr = location.search.substring(1);
    Qstr = 'sp-q=searchterm&style=style3&sp-a=sp10029b17&sp-p=all&sp-f=ISO-8859-1'; //demo, remove
    var Qstyle = Qstr.match(/style=([^&\b]+)/);
    if (Qstyle)
    	document.write(Qstyle[1]);
    
    </script>
    </body>
    </html>
    htw
    ::: certified wild guess :::

  4. #4
    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)
    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




  5. #5
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    beetle,

    Why not make that a collection under the document object, so you can do something like:
    Code:
    var style = document.queryString("style");
    Just a thought .

  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)
    Sure - easy enough to change. I've seen/heard a multitude of desired ways to get at the data. The algorithm that parses it is the important part.
    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





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
  •