iOS6 Safari orientation change bug?

前端 未结 5 1822
攒了一身酷
攒了一身酷 2020-12-17 15:52

I\'m having an rare behavior in Safari and iOS6. When changing from landscape to portrait, the viewport is resized, but it seems that is no correctly positioned horizontally

5条回答
  •  北荒
    北荒 (楼主)
    2020-12-17 16:21

    This bug also applies to IOS6 on iPhone.

    Removing and reading the placeholder in an orientationchange handler will fix the problem. This solution is jQuery specific:

    $(window).on("orientationchange", fixIOS6PlaceholderBug);
    
    function fixIOS6PlaceholderBug () {
        var $this,
            originalPlaceholder = "";
    
        $(document).find("input[placeholder]").each(function() {
            $this = $(this);
            originalPlaceholder = $this.attr("placeholder");
            $this.removeAttr("placeholder").attr("placeholder", originalPlaceholder);
        });
    }
    

提交回复
热议问题