Recently found in the project the same code in the Android Web page click on the text box to call out the virtual keyboard will not obscure the text box, but in the iOS side of the page click on the text box called the keyboard but in most cases will obscure the text box
After the expert guidance, the problem finally solved
Here's the solution:
Main code
Document.body.scrollTop = Document.body.scrollHeight;
Then when the text box gets the focus, you can define a timer that executes the sentence above
When the text box loses focus, remove the previous timer
JS notation:
Let interval;
Get text Box Object
Let text = document.getElementById (' text '). getElementsByTagName (' textarea ') [0];
message box Get focus
Text.onfocus = function () {
Interval = setinterval (function () {
Scrolltoend ();
}, 500)
};
message box loses focus
Text.onblur = function () {
Clearinterval (interval);
};
Scroll to the bottom
function Scrolltoend () {
Document.body.scrollTop = Document.body.scrollHeight;
}
jquery notation:
Let interval;
Let Text = $ (' #text textarea ');
message box Get focus
Text.focus (function () {
Interval = setinterval (function () {
Scrolltoend ();
}, 500)
});
message box loses focus
Text.onblur (function () {
Clearinterval (interval);
});
Scroll to the bottom
function Scrolltoend () {
Document.body.scrollTop = Document.body.scrollHeight;
}
Solving the problem of virtual keyboard occlusion text box under iOS system