home *** CD-ROM | disk | FTP | other *** search
/ Organic Chemistry (8th Edition) / Image.iso / pc / data1.cab / Media_Files / js / querystring.js < prev    next >
Encoding:
JavaScript  |  2003-05-14  |  1.3 KB  |  63 lines

  1. // Edugen JavaScripts Library V1.0 =========================================
  2. //
  3. //     File querystring.js
  4. //     
  5. //     This file is part of the Edugen JavaScripts Library.
  6. //     Copyright (c) 2002 WWL Corp. - A Subsidiary of John Wiley & Sons, Inc.
  7. // =========================================================================
  8. function PageQuery(q)
  9. {
  10.     if (q.length > 1)
  11.         this.q = q.substring(1, q.length);
  12.     else
  13.         this.q = null;
  14.     
  15.     this.keyValuePairs = new Array();
  16.     if (this.q)
  17.     {
  18.         for (var i=0; i < this.q.split("&").length; i++)
  19.         {
  20.             this.keyValuePairs[i] = this.q.split("&")[i];
  21.             //alert(this.keyValuePairs[i]);
  22.         }
  23.     }
  24.     
  25.     this.getKeyValuePairs = function()
  26.     {
  27.         return this.keyValuePairs;
  28.     }
  29.     
  30.     this.getValue = function(s)
  31.     {
  32.         for(var j=0; j < this.keyValuePairs.length; j++)
  33.         {
  34.             if (this.keyValuePairs[j].split("=")[0] == s)
  35.                 return this.keyValuePairs[j].split("=")[1];
  36.         }
  37.         return false;
  38.     }
  39.     
  40.     this.getParameters = function()
  41.     {
  42.         var a = new Array(this.getLength());
  43.         
  44.         for (var j=0; j < this.keyValuePairs.length; j++)
  45.         {
  46.             a[j] = this.keyValuePairs[j].split("=")[0];
  47.         }
  48.         return a;
  49.     }
  50.     
  51.     this.getLength = function()
  52.     {
  53.         return this.keyValuePairs.length;
  54.     } 
  55.  
  56. }
  57.  
  58. function queryString(key)
  59. {
  60.     var page = new PageQuery(window.location.search);
  61.     return unescape(page.getValue(key)); 
  62. }
  63.