title: window.location.href not working in Safari when using onkeypress
body: <p>I'm using an asp textbox and a search button. In Safari if I click the search button i get redirected to the search results page using javascript window.location.href. But strangely the same javascript will not redirect to the page if I press return in the textbox. </p>
  
  <p>Using the alert function I can see that window.location.href has the the correct url and the location bar at the top changes from the search page(default.aspx) to the search results url however when I click OK to the alert box the url at the top reverts back to the default.aspx page. It works on ie7/8/firefox/chrome but not safari. Here is my javascript,cs and aspx code:</p>
  
  <pre><code>function submitSearchOnEnter(e) {
  
              var CodeForEnter = 13;
              var codeEnteredByUser;
  
              if (!e) var e = window.event;
              if (e.keyCode) codeEnteredByUser = e.keyCode;
              else if (e.which) codeEnteredByUser = e.which;
  
              if (codeEnteredByUser == CodeForEnter)
                  RedirectToSearchPage();
          }
  
          function RedirectToSearchPage() {
  
              var searchText = $get('&lt;%=txtHeaderSearch.ClientID%&gt;').value
  
              if (searchText.length) {
  
                  window.location.href = "Search.aspx?searchString=" + searchText;
              }
          }
  
  protected void Page_Load(object sender, EventArgs e)
  {
      txtHeaderSearch.Attributes.Add("onkeypress", "submitSearchOnEnter(event)");
  }
  
  &lt;asp:Panel ID="pnlSearch" runat="server" DefaultButton="lnkSearch"&gt;
                  &lt;asp:TextBox ID="txtHeaderSearch" runat="server" CssClass="searchBox"&gt;&lt;/asp:TextBox&gt;
                  &lt;asp:LinkButton ID="lnkSearch" OnClientClick="RedirectToSearchPage(); return false;"
                      CausesValidation="false" runat="server" CssClass="searchButton"&gt;
              SEARCH
                  &lt;/asp:LinkButton&gt;
              &lt;/asp:Panel&gt;
  </code></pre>
  
  <p>I've tried return false; which doesn't allow me to enter any characters in the search box. I've spent ages online trying to find a solution. Maybe it has something to do with setTimeout or setTimeInterval but it didn't work unless i did it wrong.</p>