I have a website and it works correctly in Desktop and Androids.
When I check my website in Iphone, there are 2 things that are wrong
Size Value in HTML input tag does not increase the size of input but it depends on Max Value
When i scroll down my website while it loads more contents, the page scroll up to the beginning which is different in Desktop and Androids.
Is there any solution to fix this like changing some my HTML and Javascript codes in order it to work correctly in Iphone browser?
These are my codes:
<input min="1" max="200" value="1" maxlength="7" required size="7">
if ((window.innerHeight + window.scrollY) >= (document.body.offsetHeight - 50)){//Loads}
Solution: Use CSS to control the size, not the size or max attribute.
<input
type="number"
style="width: 100px;"
min="0"
max="9999"
inputmode="numeric"
/>
// For small devices like iPhone
@media screen and (max-width: 500px) {
input[type="number"] {
width: 100px;
}
}
Solution: Use position: relative on containers
.container {
position: relative;
}
If you’re loading content with JavaScript, manually preserve scroll:
const scrollPos = window.scrollY;
loadMoreContent(); // append content
window.scrollTo({ top: scrollPos });