title: Getting URL data with JavaScript (split it like php $_GET)
body: <p>I found this script at Stack&nbsp;Overflow:</p>
  
  <pre><code>window.params = function(){
      var params = {};
      var param_array = window.location.href.split('?')[1].split('&amp;');
      for(var i in param_array){
          x = param_array[i].split('=');
          params[x[0]] = x[1];
      }
      return params;
  }();
  </code></pre>
  
  <p>This splits a URL into data, like PHP does with <code>$_GET</code>.</p>
  
  <p>I have another function, which uses it and it refreshes the iframe. I want to get the data from the URL and add another with it if some of these data exist. <a href="http://en.wikipedia.org/wiki/Firebug_%28software%29" rel="nofollow">Firebug</a> shows me, that <code>search</code> is not defined, but why?</p>
  
  <pre><code>function RefreshIFrames(MyParameter) {
      var cat = window.params.cat;
      var category = window.params.category;
      var search = window.params.search;
  
      if (search.length&gt;0 &amp;&amp; category.length&gt;0){
          window.location.href="http://siriusradio.hu/kiskunfelegyhaza/video/index.php?search="+search+"&amp;category="+category+"&amp;rendez="+MyParameter;
      }
  
      if (cat.length&gt;0){
          window.location.href="http://siriusradio.hu/kiskunfelegyhaza/video/index.php?cat="+cat+"&amp;rendez="+MyParameter;
      }
  
      if (cat.length==0 &amp;&amp; category.length==0 &amp;&amp; search.length==0){
          window.location.href="http://siriusradio.hu/kiskunfelegyhaza/video/index.php?rendez="+MyParameter;
      }
      alert(window.location);
  }
  </code></pre>