title: a href=javascript different across browsers, strange behavior
body: <p>I have a site that relies on a JSON file that PHP parses to output a navbar (I built an editor so the customer can maintain content).  A link in the JSON file has this structure:</p>
  
  <pre><code>"Text to Display": {
      "href": "myPage.php",
      "child": {
          "Text for Child Link": {
              "href": "secondPage.php",
              "child": {}
          }
      }
  </code></pre>
  
  <p>And a recursive function (PHP) to loop over it and output the navbar such as:</p>
  
  <pre><code>function block_menuList($links) {
      $o='';
      foreach ($links as $k =&gt; $v) {
          $href='javascript:void(0)'; // default to link nowhere
          if (isset($v['href'])) $href=$v['href']; // pull link from array
          $o.="&lt;li&gt;&lt;a href='$href'&gt;$k&lt;/a&gt;"; // output list item
          if (isset($v['child']) &amp;&amp; is_array($v['child'])) $o.="&lt;ul&gt;".block_menuList($v['child'])."&lt;/ul&gt;"; // if there's a child list call recursively
          $o.="&lt;/li&gt;";
      }
      return $o;
  }
  </code></pre>
  
  <p>The site runs on a hash model system, and I'd like to be able to add links to change the hash model without having to switch this to conditionally use onclick instead of href.  The javascript is not responding how I expect it to.  I should be able to correctly use:</p>
  
  <pre><code>&lt;a href="javascript:location.hash=buildHash('c=8')"&gt;My Link&lt;/a&gt;
  </code></pre>
  
  <p>Instead of working, however, things like this happen:</p>
  
  <ul>
  <li>Firefox's URL bar says <code>javascript:location.hash=buildHash('c=8')</code> and the content is <code>#c=8</code>, and hitting the back arrow takes me to the expected target.</li>
  <li>Chrome kept the URL bar the same, but replaced the body's HTML with <code>#c=8</code></li>
  </ul>
  
  <p>I can define the link like this and everything works fine:</p>
  
  <pre><code>&lt;a href="javascript:void(0)" onclick="location.hash=buildHash('c=8')"&gt;My Link&lt;/a&gt;
  </code></pre>
  
  <p>Calls to <code>buildHash</code> from javascript work as well, for example in JQuery event listeners.  Only the <code>&lt;a href="javascript:something()"&gt;</code> method seems to be broken, but a simple test of <code>&lt;a href="javascript:alert('yu no build hash?')"&gt;</code> runs and shows the alert box.</p>
  
  <p>edit: Due to this structure I won't be able to bind JS/JQuery events.  Here's the full object I'm using on site right now so my issue is easier to understand:</p>
  
  <pre><code>{
      "Home": {
          "href": "index.php",
          "child": {
              "About Us": {
                  "href": "view.php?pg=about",
                  "child": {}
              },
              "Contact Us": {
                  "href": "view.php?pg=contact",
                  "child": {}
              },
              "Location &amp; Hours": {
                  "href": "view.php?pg=location",
                  "child": {}
              },
              "News": {
                  "href": "news.php",
                  "child": {}
              }
          },
          "parent": true
      },
      "Products": {
          "href": "cart.php",
          "child": {
              "categories": {
                  "href": "categories",
                  "child": {}
              }
          },
          "parent": true
      },
      "Sales": {
          "href": "javascript:filterModel.goto(\"sl=1\", \"\")",
          "child": {},
          "parent": true
      },
      "Clearance": {
          "href": "javascript:filterModel.goto(\"cl=1\", \"\")",
          "child": {},
          "parent": true
      },
      "My Account": {
          "href": "account.php",
          "child": {
              "Order Status": {
                  "href": "ordStat.php",
                  "child": {}
              },
              "Order History": {
                  "href": "ordHist.php",
                  "child": {}
              }
          },
          "parent": true
      }
  }
  </code></pre>