title: Can't Set Focus in Safari
body: <p>I'm trying to set focus to a particular edit field when a page opens or button is pressed.  The following simple HTML/Javascript (Test.html) works with Firefox and Chrome but not Safari.  Safari will clear the text with the clear button and post it with find button but not select it when the select button is pressed.  Any help would be appreciated.  (iOS 7 on an iPad 2)</p>
  
  <p>Update -- Replaced with working code</p>
  
  <pre><code>&lt;html&gt;
  
  &lt;head&gt;
  
  &lt;!-- Latest JQuery; Must be loaded before Bootstrap --&gt;
  &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;!-- Latest compiled and minified Bootstrap CSS --&gt;
  &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"&gt;
  
  &lt;!-- Latest compiled and minified JavaScript --&gt;
  &lt;script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"&gt;&lt;/script&gt;
  
  &lt;/head&gt;
  
  
  &lt;script&gt;
  $(document).ready(function()
  {
      var identNum = document.getElementById("identNum");
      identNum.value = "AAAABBBB111"
      identNum.focus();
      identNum.setSelectionRange(0, identNum.value.length);
  });
  &lt;/script&gt;
  
  
  &lt;body&gt;
  
  
  &lt;div&gt;
      &lt;form class="form-horizontal" name="myForm" role="form" action="Test" method="post"&gt;
          &lt;div class="form-group" align="center"&gt;
              &lt;div&gt;
                  &lt;label class="control-label"&gt;Text:&lt;/label&gt;
                  &lt;input type="text" id="identNum" name="identNum" size="25" value="" style="text-align:center;'"&gt;
              &lt;/div&gt;
  
              &lt;div&gt;
                  &lt;button class="btn btn-primary"&gt;Find&lt;/button&gt;
                  &lt;a class="btn" onclick="javascript:document.getElementById('identNum').value=''" &gt;Clear&lt;/a&gt;
                  &lt;a class="btn" onclick="javascript:document.getElementById('identNum').focus(); document.getElementById('identNum').setSelectionRange(0, identNum.value.length)" &gt;Select&lt;/a&gt;
              &lt;/div&gt;
  
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>