Prevent Safari (iPhone) to show an URL bar on form

2019-09-19 09:51发布

I have found several javascript fixes to hide the Safari URL bar, great.

However it seems that form input fields tend to toggle it visible again if you've hidden it previously.. Is there a way to prevent this behaviour?

If it's not possible I guess I have to add an eventlistener that gives me a style hook on the URLs bar whereabouts..

2条回答
甜甜的少女心
2楼-- · 2019-09-19 10:49

Found a fix..

setTimeout(function () {
    window.scrollTo(0, 1);
}, 500);

$(document).ready(function(){
    $('input').click(function(){
        window.scrollTo(0,0);
    });

stops the input behaviour..

查看更多
男人必须洒脱
3楼-- · 2019-09-19 10:53

I've found another solution

$('body')
    .on('touchstart', 'input', function(e) {
        e.target.focus();
        return false;
    })
    .on('focus', 'input', function() {
        window.scrollTo(0, 0);
        return false;
    });

Address bar doesn't show at all with this code

查看更多
登录 后发表回答