How to prevent keyboard push up webview at iOS app using phonegap
On focus, set window.scrollTo(0,0); This prevents keyboard from pushing up webview completely
$('input').on('focus', function(e) {
e.preventDefault(); e.stopPropagation();
window.scrollTo(0,0); //the second 0 marks the Y scroll pos. Setting this to i.e. 100 will push the screen up by 100px.
});
If you don't want to set a static value for your Y scroll position, feel free to use this short plugin I've written that automatically aligns the keyboard underneath the input field. It's not perfect, but it does the job. Just call this on focus as shown above:
setKeyboardPos(e.target.id);
android keyboard displaces the ion-content by pushing it up
Finally I managed to fix this, just after I posted this question:
For anybody else that may be having this issue, what worked for me was:
In the AndroidManifest.xml file (located in platforms\android directory), change the attribute to:
android:windowSoftInputMode="adjustPan"
<activity
...
...
android:windowSoftInputMode="adjustPan">
...
</activity>
How to prevent iOS keyboard from pushing the view off screen with CSS or JS
first
<script type="text/javascript">
$(document).ready(function() {
document.ontouchmove = function(e){
e.preventDefault();
}
});
then this
input.onfocus = function () {
window.scrollTo(0, 0);
document.body.scrollTop = 0;
}
Related Topics
Nsattributedstring Superscript Styling
How to Lookup a String Constant at Runtime in Objective-C
Moving the Cursor to the Beginning of Uitextfield
Nsxmlparser: Unexpected Result with Non-Ascii Characters
Exc_Bad_Instruction When Passing Uicollectionview Cell Data to Different Viewcontroller
Xcode Simulator: How to Remove Older Unneeded Devices
How to Use Core Location/Gps Without Any Internet Connection/Disabled Cellular Network
What Is Sandbox in iOS? How to Transfer Data Between One App to Another App
How to Force a Hkquery to Load the Most Recent Steps Counts
Xcode - Bundle Format Unrecognized, Invalid, or Unsuitable
Swiftui Datepicker Binding Optional Date, Valid Nil
Unexpected Non-Void Return Value in Void Function Swift3
Core Data in Swift: Only Saving Last Object in a for Loop
Open Uitableview Edit Action Buttons Programmatically
Posting Photo to Facebook Fan Page via iOS App by Regular Non-Admin Users