How to Prevent Keyboard Push Up Webview at iOS App Using Phonegap

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



Leave a reply



Submit