title: window.scrollTo not working in phonegap - alternative solution or workaround?
body: <p>I've written a rather basic js function that programatically and automatically <strong>aligns the iPhone keyboard perfectly underneath each and every input field</strong> that gets focused (<em>feel free to use it if you like it</em>!). The alignment's primarily handled by window.scroll - a standard method that works in any browser view, except in UIWebView hence <em>phonegap/cordova (2.1)</em>. <strong>So I need a workaround</strong>. </p>
  
  <p><strong>My working code:</strong></p>
  
  <pre><code>function setKeyboardPos(tarId) {
  
  //programmatically: set scroll pos so keyboard aligns perfectly underneath textfield
  var elVerticalDistance = $("#"+tarId).offset()["top"]; //i.e. 287
  var keyboardHeight = 158;
  var heightOfView = document.height; // i.e. 444
  var inputHeight = $("#"+tarId).outerHeight();
  
  var viewPortSpace = heightOfView-keyboardHeight; //i.e. 180
  var verticalNewSroll = (elVerticalDistance+inputHeight)-viewPortSpace;
  if(verticalNewSroll&lt;0) { verticalNewSroll = 0; }
  ////
  
      //OK, all done lets go ahead with some actions
      $("#footer").hide(); //hide footer so that the keyboard doesn't push it on top of textfield
      $("#containingDiv").css("bottom","0px"); //remove bottom space for footer
      window.scrollTo(0,verticalNewSroll); //scroll! where the problem starts
  
  
  }
  </code></pre>
  
  <p><em>Working in everything but UIWebView, that is.</em> As I mentioned above, everything works except the window.scrollTo (N.B. some minor changes have been made for the sake of clarity). So does anyone know of an alternative solution or even a good workaround?</p>
  
  <p><strong>Similar questions</strong></p>
  
  <p><a href="https://stackoverflow.com/questions/13313721/window-scrollto-doesnt-work-in-phonegap-for-ios">window.scrollTo doesn&#39;t work in phonegap for IOS</a></p>
  
  <p><a href="https://stackoverflow.com/questions/11781054/phonegap-cordova-scrollto-ignored">PhoneGap / Cordova scrollTo Ignored</a></p>
  
  <p><a href="https://stackoverflow.com/questions/11594080/how-to-add-vertical-scroll-in-phonegap">How to add vertical scroll in Phonegap</a></p>
  
  <p>Above are furthermore three similar questions that somewhat points one in the right direction. One of the answerers mentions <strong>the use of css to accomplish this</strong>. Can anyone come up with a more concrete example? <strong>Another guy suggests anchors</strong> but that's not a very pretty solution and doesn't go very well with the rest of my code.</p>