Solving the Issue of Overflow Content Scroll on iOS/iPad 2

I'm facing an issue where I am unable to get the mobile Safari browser to scroll within an iframe on iOS, instead of extending the document to display the entire content.

To provide some context, my document structure looks like this —

When attempting to horizontally scroll on nav.html with overflow-x: scroll and '-webkit-overflow-scrolling: touch;', it doesn't work when testing on iOS 7 on the iPad 2. Even testing in the iOS simulator has not yielded any success.

The problem arises on the product pages accessible here — .

The above link is an iFrame wrapping the body of the main website. In the main website, there are index.html page with two iframe containers; one for the product (iframe[name='viewer']), and another for the navigation (iframe[name='nav']). The viewer iframe has overflow: auto set and works on overflow-y content. However, for the nav, the content extends beyond the set width container, overflowing the entire document, rather than just the nav within the div.nav in the nav iframe.

This is how my index.html markup looks with both iframes (product/[product_number].html and nav.html) —

<body class="cat">
  <div class="back-nav-cat"></div>
  <!-- Navigation Links -->
  <div class="cat-navigation back" onclick="location.href='../index.html';">BACK</div>
  <!-- Viewer -->
  <iframe src="products/P-715.html" frameborder="0" name="viewer" width="2560" height="1195" scrolling="no"></iframe>

  <!-- Nav -->
    <iframe src="nav.html" frameborder="0" name="nav" width="2560" height="245" scrolling="yes" style="position: absolute;"></iframe>
</body>

If anyone knows 1) the cause of this issue, and 2) a proven solution, your help would be greatly appreciated.

Just a heads up: the domain is a test domain for our agency, so approach with caution (some have mistaken it for a virus.... which was definitely not our intention).

Thank you in advance.

EDIT:

Credit to Ryan Wheale, all I needed to do was set the width of my nav iframe to width: 100%. Additionally, I wrapped the iframe in a div with overflow-x: scroll; and

-webkit-overflow-scrolling: touch;
.

Answer №1

overflow does not affect frames. To ensure the frame always fits on the screen, set the width to a percentage value such as 100%. Once the content inside the frame exceeds its available space, scrolling will automatically activate (assuming scrolling="yes" is specified in the iframe attributes).

For iOS compatibility, include a wrapping DIV with specific CSS:

.iframe-wrapper {
    -webkit-overflow-scrolling: touch;
    overflow-x: scroll;
}

<div class="iframe-wrapper">
    <iframe scrolling="yes" width="100%" height="200px"></iframe>
</div>

In my opinion, using frames for this purpose is outdated and should be avoided. Consider a simpler alternative by utilizing jQuery and replacing iframes with DIV elements assigned IDs:

$('#main').load('products/P-715.html');
$('#nav').load('nav.html');

Answer №2

What is the purpose of using iframes?

It seems like the size of your "viewer" element is larger than the actual content within it, causing a lack of scrolling ability as per your explanation. I would recommend swapping the heights of the elements and ensuring that your content (such as images or text) is enclosed within a parent wrapper. When elements are not properly nested, there is no relationship between them, resulting in the absence of scrolling functionality.

Here's an example:

HTML

<div class="viewer">
  <div class="content"></div>
</div>

CSS

div.viewer {
    width:                              2000px;
    height:                             500px;
    overflow-x:                         scroll;
}

div.content {
    width:                              2000px;
    height:                             1000px;
}

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

Tips for preventing the reinitialization of a jQuery object as a function multiple times

I have initialized an object as smartphoto using the following code snippet: $(".js_smartphoto").SmartPhoto(); When a user clicks the paging button, the code loops through all list items inside and assigns the function again. This results in the smartph ...

Creating a Div element to occupy an entire row is a simple task that can be achieved

Seeking a solution to automatically generate a DIV when our products do not fill up the entire row, using the MixItUp jQuery filter and sort plugin. Is there a JavaScript code that can detect the empty space in a row and create the necessary div to mainta ...

Utilize MaterialUI Grid to define custom styles for the ::after pseudo-element

I came across a helpful article on Stack Overflow about Flex-box and how to align the last row to the grid. I'm interested in implementing it in my project: .grid::after { content: ""; flex: auto; } However, I'm not sure how to inc ...

I am having trouble with Visual Studio Code and ESLint not recognizing spelling errors such as "style.backgroundCOlor". What steps can I take to resolve this issue?

Since I'm relatively new to Visual Studio Code, I recently encountered an issue with the "ESLint" extension where my typos were not being detected. These typos were in actual pieces of code, not just comments, which made it tricky to spot the errors. ...

Instructions for creating a fading effect on W3schools Modal example

After utilizing the CSS class from https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_modal_fade to achieve a fade in effect, I am now looking for a way to fade out when the modal closes. How can this be accomplished? .w3-animate-opacity{animatio ...

Having issues with Angular http.post not sending data when using subscribe

I'm currently facing an issue with sending data to my API using post.subscribe. Despite the fact that no errors are being thrown, the data is not being sent successfully. It's important to note that the API itself is functioning perfectly. Belo ...

What is causing my package bundler to constantly fail, even on the most basic tasks?

In my current project, the main index.html file includes a <link rel="stylesheet" href="./styles/styles.scss"> to import my styles. However, when I attempt to run parcel index.html, an error message pops up stating: .nvm/versions/node/v10.16.3/lib/no ...

What could be causing the lack of firing with Mobile Safari and jQuery events?

My HTML5/JavaScript app, originally designed for an in-dash car unit, is now being ported to the browser for marketing and presentation purposes. The transition seemed simple at first, just some CSS adjustments for cross-browser compatibility. However, whe ...

Column with a set width in Bootstrap

Is it possible to create a fixed width right column in Bootstrap while keeping the left column responsive? I am currently working with Bootstrap 2.3.2 https://i.stack.imgur.com/xOhQo.png (source: toile-libre.org) I want the right column to maintain it ...

Using Grails, the event listener can be triggered by a change in the

Looking for some advice on implementing a dynamic textfield element in a Grails form. I'm using the remoteFunction action to call a template, but unfortunately, the template is not being called as expected. When I switch from "g:textField" to "g:selec ...

Error: React/Express - The renderToString() function encountered an unexpected token '<'

As I work on implementing server-side rendering for my React/Express application, I have hit a snag due to a syntax error related to the use of the react-dom/server renderToString() method. In my approach, I am following a tutorial mentioned here - The sn ...

JavaScript Sort Error: 'Arithmetic operations can only be performed on variables of type 'any', 'number', 'bigint', or an enum type'

Encountering an error in my Angular 7 project related to the sort function in TypeScript. The error message states: "The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type&apos ...

Generating unique alpha-numeric random string for database using Node.js

In my current scenario, I am in need of creating alpha-numeric strings consisting of capital letters with a length of 25 characters. This results in an extremely high number of potential unique combinations: 36 pow (25) = 808281277464764060643139600456536 ...

The loading icon on Chrome continues to rotate while handling XMLHttpRequest requests

I'm currently developing a web app using AJAX with Comet/Long Polling to ensure real-time updates on the web page. I've noticed that in Chrome, the page is constantly loading (tab icon keeps spinning). Initially, I thought this was a normal beha ...

An unidentified non-space character appeared following the JSON data on line 1, which was unexpected and at column

I am currently working on a WordPress site locally and my goal is to develop a hybrid app for it using AngularJS. Within WordPress, I have created a plugin to retrieve data. The metadata comes in the form of an array: (...) After converting this complex ...

Wait for AJAX to finish before continuing the loop in Javascript

Is it possible to halt a loop until each AJAX request has returned for every iteration? for (var i = 0; i < 5; i++) { var data = "i=" + 1; var ajax = $.ajax({ url: '/ajax.php', type: 'post', dat ...

Having trouble with the responsive design not functioning properly?

Having trouble with mobile view in my simple HTML Bootstrap code. Everything looks fine in desktop view but not in mobile. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < ...

What is the reason for jQuery displaying undefined when attempting to retrieve a custom data attribute using .prop()?

In my dynamic HTML generated by JavaScript, the following code snippet is included: $(".task-status").live("click", function () { alert("data-id using prop: " + $(this).prop("data-id")) alert("data-id using data: " + $(this).data("id")) ...

Tips for adding a class to an SVG when clicked

I want to make an SVG change color to white when clicked and its container (icon_container) to change to blue. How can I achieve this? Below is the code snippet: state = { active: false, }; click = () => { this.setState({active: !this.state.active ...

Retrieving registered components dynamically in Vue.js

Check out my scenario on jsBin In my setup, I have a selector <component :is="selectedComponent"></component>, along with a <select v-model="currentComponent">...</select> that allows me to choose which one is displayed. Currently ...