Incorrect page height displayed in the embedded Facebook browser on iOS 9.x

When trying to access the demo application from core-layout using the embedded browser within the Facebook app on iOS 9.x, it appears that the footer element is not visible in portrait mode. When the device is rotated to landscape mode, the footer becomes partially visible instead of being completely visible as expected.

The first image depicts how the demo app is supposed to appear, while the second image displays the issue of the missing footer when viewed through the Facebook app's embedded web view (the images were captured from a Chrome desktop browser showcasing the bug):

https://i.sstatic.net/Pv4W8.png https://i.sstatic.net/X3NgI.png

After exploring various possibilities, we discovered that the bug stemmed from the browser rendering the page/viewport taller than the visible area.

This problem appeared to be linked to issues discussed in threads such as iOS9 Safari viewport issues, meta not scaling properly? and Web page not getting 100% height in Twitter app on iOS 8.

Answer №1

After thorough research and attention to detail, we devised a solution that combined various answers from StackOverflow. It's important to note that implementing only certain changes did not resolve the issue; all modifications outlined below were necessary.

  • We had to modify the CSS defining the height of the enclosing div element (#outer-wrap) as follows:

    outer-wrap {
      position: absolute;
      width: 100%;
      height: 100%;
      overflow: hidden;
    }
    

    to

    html, body, #outer-wrap {
      position: absolute;
      top: 0;
      left: 0;
      bottom: 0;
      right: 0;
      overflow: hidden;
    }
    
  • We added the following function to our library, which is called during initialization:

    function _fixViewportHeight() {
        var html = document.querySelector('html');
    
        function _onResize(event) {
            html.style.height = window.innerHeight + 'px';
        }
    
        window.addEventListener('resize', _.debounce(_onResize, 125, {
            leading: true,
            maxWait: 250,
            trailing: true
        }));
    
        _onResize();
    }
    
    _fixViewportHeight();
    
  • The viewport meta tag needed to be altered to:

    <meta name="viewport"
      content="width=device-width, initial-scale=1.0, maximum-scale=1.0, target-densityDpi=device-dpi">
    

    It's crucial to use a scale value of 1.0, not 1, to prevent issues with tools like html-minifier. We resolved the html-minifier problem by encapsulating the viewport meta tag within <!-- htmlmin:ignore --> comments.

Answer №2

Encountered a similar issue, however, I found that utilizing window.innerHeight resolved it for me rather than using document.body.clientHeight.

Answer №3

If you're seeking alternative solutions to Martin's response, consider adjusting your CSS based on detecting the Facebook in-app browser.

The issue I encountered revolved around CSS - specifically, bottom elements being obscured.

function modifyCSSforFbBrowser() {
  var userAgent = navigator.userAgent || navigator.vendor || window.opera;
  if (isFacebookApp(userAgent)) { // Identifying Facebook in-app browser
      $('.bottombar').css('height', '50vh'); // Making CSS adjustment
  }
};

Subsequently:

$(document).ready(function() {
  modifyCSSforFbBrowser();
  ...

Answer №4

In order to understand the issue with the height bug, it is essential to comprehend how the FB in-app browser functions: it undergoes an opening animation where the size of the browser increases from bottom to top. This dynamic causes discrepancies in the calculated height by JavaScript on the initial page load.

  • window.innerHeight,
  • document.documentElement.clientHeight,
  • document.body.clientHeight
  • element.style.height='100vh'

The calculated height may be inaccurate initially as JavaScript can run during the opening animation while the browser's height is still adjusting.

To resolve this issue, I utilized screen.height as a constant reference point for height calculation.

To identify when the app is opened in the Facebook in-app browser, I implemented a function found here: How to detect Facebook in-app browser?

function isFacebookApp() {
    var ua = navigator.userAgent || navigator.vendor || window.opera;
    return (ua.indexOf('FBAN') > -1) || (ua.indexOf('FBAV') > -1);
}

P.S. A similar issue could arise with width calculations, where using screen.width can offer a solution.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

delivering the user's ID and username from php back to the website

Currently, I am in the process of creating a sign-in feature for my website (index.php): To achieve this, I have designed a form that will submit information to the validation-sign-in.php file for processing: (Encryption will be implemented at a later st ...

Ways to extract information from PayFast

One issue I'm facing with my online store is that although PayFast does call my notify_url, it appears that no data is being posted. Below are the codes I've been using: Code for purchasing: <button id="cCart" type="submit" class="bt ...

Library of User Interface components for React Native applications

As I embark on my journey of building my first major app using React Native, a question comes to mind. Is there a UI framework available for React Native that offers pre-styled components right out of the box? Similar to how Ionic provides a base theme a ...

Design a dynamic rectangular division using CSS and Bootstrap 4 that adapts to different screen sizes

I am encountering difficulties attempting to replicate a full-width rectangle div on a website, particularly with issues related to responsiveness and mobility. Here is an example of the design I am trying to recreate. And here's what I've acco ...

Elevate a division within its container

Is there a way to make a smaller div positioned at the top when it's placed next to a larger one in the same container? I'm looking for a solution that doesn't involve using position-relative and manually adjusting the placement. Take a loo ...

Obtaining a byte array using the file input method

var profileImage = fileInputInByteArray; $.ajax({ url: 'abc.com/', type: 'POST', dataType: 'json', data: { // Other data ProfileImage: profileimage // Other data }, success: { } }) // Code in Web ...

What is the method to extract the content located within the <body> element using requests.get()?

I attempted to utilize: from json import loads from requests import get text_inside_body_tag = loads(get('https://Clicker-leaderboard.ge1g.repl.co').content) However, it keeps throwing an error related to loads expecting a bytes object or when ...

Problem with overlapping numbers in the Vis network

I am currently working on a project using Angular 8 and Visnetwork. Everything is going well, but I am facing an issue with overlapping numbers on lines. Is there a way to adjust the position of the numbers on one line without separating the lines? Can s ...

Explore relevant Pill information dynamically based on the image that was clicked in Angular

In this particular situation: Using Angular 1.7.2 Utilizing Bootstrap 3 Encountering some challenges after the user interacts with the image: Current Behavior: Upon clicking any image, a modal window appears displaying relevant content. If image 1 is ...

Clicking on tabs causes their content to mysteriously vanish

I am working on creating a dynamic menu using jQuery that switches content based on tabs. However, I am facing an issue where clicking on a different <li> item causes the content to disappear. Each list item should correspond to different content sec ...

Background in CSS ::after pseudo-element not showing up

I've been attempting to show a tick image after a div element, but no matter what CSS properties I try, I can't seem to get it right. Previous answers to similar questions haven't provided the solution I need. HTML: <div class="link-in ...

Tips for safeguarding against the insertion of scripts into input fields

Is there a method to stop users from inputting scripts into text fields or text areas? function filter($event) { var regex = /[^a-zA-Z0-9_]/; let match = regex.exec($event.target.value); console.log(match); if (match) { $event.pre ...

Opera bug causing issues with Bootstrap's :active list item styling

Lately, I've been delving into Bootstrap and have come across an issue while using Opera. Upon the webpage loading, the navbar should display a list structured as follows: <li class="hidden active"> <li class="page-scroll"> <li class=" ...

Make sure to place the <i> tag within the <li> tag at the bottom to automatically resize the height

Currently, I am working on customizing my menu design with a mix of bootstrap and font awesome CSS styles. It would be easier to demonstrate the issue on a live page. My main objectives are two-fold: I want to position the chevron icon at the bottom with ...

Swap File Field for Picture Graphic - HTML/CSS

I am looking to enhance the appearance of my form by replacing the generic File Field with a more aesthetically pleasing Image Icon. If you click on this Camera Icon, it will open up a Browse window: For a demonstration, check out this JsFiddle link: htt ...

Prevent content overlap in Tumblr's sidebars by using CSS positioning techniques

I'm facing an issue with my blog on Tumblr where the sidebar keeps overlapping the main content. I have modified a premade template and am trying to position the sidebar in the top right corner using absolute or fixed positioning: #sidebar{ position: ...

Conceal the toolbar element if it is not at the top of the page

I am encountering an issue with my toolbar. When I scroll down, the transparent background of the toolbar disappears and it looks like this: https://i.sstatic.net/YxZQe.png. How can I hide this component when the page is scrolled down and show it again whe ...

How to Retrieve Content from an iFrame Using jQuery?

I am facing a challenge with an HTML form that is directed to an IFRAME upon clicking "submit". The iframe then loads a page after the submission, which indicates whether the user-input data is valid or not. It simply displays on screen as "TRUE" or "FALSE ...

Angular: monitoring changes in HTML content within a Component or Directive

I have a situation where I am retrieving HTML content from a REST endpoint using a directive and inserting it into a div element using [innerHTML]. Once this HTML content is rendered, I would like to manipulate it by calling a global function. My approach ...

Warning: Potential Infinite Loop when using Vue JS Category Filter

I developed a program that filters events based on their program and type. The program is working correctly, however, an error message stating "You may have an infinite update loop in a component render function" keeps popping up. I suspect that the issue ...