iOS users experiencing issues with displaced iframes when dragging

I am currently facing an issue with the iframe on my website. Whenever the Make an Appointment button is clicked, the iframe displays a contact form with multiple input fields.

Although everything seems to be functioning properly, I have noticed that on iOS devices (such as iPad and iPhone 5/6 - tested on Safari and Chrome), the form can be dragged beyond the width and height of its container. This behavior should only allow vertical scrolling, similar to how it works on Android devices. Refer to the screenshot below for clarification.

Despite searching through various discussions on platforms like S/O, I have yet to come across any relevant questions or answers related to this specific quirk in iOS devices/browsers.

Below is the code snippet:

HTML:

<div id='button'><button id='contact'>MAKE AN APPOINTMENT</button></div>
    <div id="block"></div>
       <div id="iframecontainer">
           <a id='close' href='#'>X</a>
          <div id="loader"></div>
        <iframe></iframe>
    </div>

JQuery:

$('document').ready(function() {
  $('#contact').click(function () {
    $('#block').fadeIn();
    $('#iframecontainer').fadeIn();
    $('#header-wrapper').css("visibility", "hidden");
     var width = $(window).width();
    $('#iframecontainer iframe').attr('src', 'http://a-link-to-my-iframe.html');
    if (width > 850) {
        $('#iframecontainer').css('width', '790px');
        $('#iframecontainer').css('margin-left', '-395px');
    }
    else {
        $('#iframecontainer').css('width', '310px');
        $('#iframecontainer').css('margin-left', '-155px');
    }
    $('#iframecontainer iframe').load(function() {
         $('#loader').fadeOut(function() {
            $('iframe').fadeIn();
         });
     });
   });

Additionally, here is the CSS used in this context:

#contact {
  color: #c2c2c2;
  background: #151515;
  border: 1px solid #c2c2c2;
  padding: 13px 26px;
  text-decoration: underline;
  font-family: inherit;
  letter-spacing: 2px;
  font-size: 18px;
  margin: 0 auto;
}
#iframecontainer {
  width:75%; 
  height: auto; 
  display: none; 
  position: fixed;
  -webkit-overflow-scrolling:touch;
  overflow-y: auto;
  height:600px;
  top: 10%; 
  background:#FFF; 
  border: 1px solid #666;
  box-shadow: 2px 2px 40px #222;
  z-index: 999999;
  left: 50%;
  margin-left: -395px;
}
#iframecontainer iframe { 
  width: 100%; 
  height: 600px; 
  position: absolute; 
  border: none; 
}
#loader { 
  width: 250px; 
  height: 250px; 
  margin:auto;
}
#block {
  background: #000; 
  opacity:0.6;  
  position: fixed; 
  width: 100%; 
  height: 100%; 
  top:0; 
  left:0; 
  display:none;
}​

Lastly, you can view a screen shot illustrating the issue by clicking here.

Is there a specific method to prevent this draggable behavior on iOS devices?

Answer №1

To prevent scrolling, you can include scrolling="no" in the iframe code and also adjust the CSS properties of the iframe, like so:

#iframe-wrapper iframe {
  width: 1px; /* Set a small width to fit the viewport */
  min-width: 100%; /* Override the width for dynamic sizing */
  height: 600px;
  position: absolute;
  border: none;
}

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

Learn how to easily upload multiple files from various upload points onto a single page using Node.js and express-fileupload

After searching on various platforms, including StackOverflow, I couldn't find a solution that fits my specific scenario. I've been struggling for hours to resolve this issue... In my handlebars page, there is an option for the user to upload fi ...

Mongodb Retrieving results and their opposites

Can you retrieve results that match a specific query and those that do not in a single query? Assume I have the following data: { name: 'name1', age: 19 }, { name: 'name2', age: 20 }, { name: 'name3', ...

Fundamentals of Filtering with Angular

Greetings everyone, I am new to Angular and seeking assistance. I am encountering difficulties with Angular filters when using a data-binded value. <!DOCTYPE html> <html> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6. ...

$q, postponement, and fractional deployment

I can't figure out why this code isn't functioning as anticipated: func = -> deferObj = $q.defer() $timeout -> deferObj.resolve({foo:'bar'}) ,1000 return deferObj.promise showData = (data)-> console.l ...

Organize rows in a table with PHP

Currently, I am utilizing jQuery to sort table rows through drag and drop. However, I'm encountering an issue after saving the order to the database. How can I ensure that the table maintains its sorting upon page refresh or reload? Essentially, my t ...

How can I convert a string to an integer in Node.js/JavaScript in terms of cardinality?

Imagine a scenario where a user can input any string such as "1st", "2nd", "third", "fourth", "fifth", "9999th", etc. The goal is to assign an integer value to each of these strings: "1st" -> 0 "2nd" -> 1 "third" -> 2 "fourth" -> 3 "fifth" -&g ...

Tips for retrieving specific database entries using a JavaScript function

I'm currently in the process of developing a web directory that showcases organizations based on the selected county by utilizing an XML database. During testing, I have configured it to only display organization names and counties for now. However, ...

What is the reason behind the jquery .data() method not retrieving the recent value?

I have created FilePanels that include folders and subfolders. When inspecting in Chrome Developer Tools, I noticed that ui.item.sortable.droptarget has a data attribute with parent-folder-id == 2, but accessing it through jQuery's data method return ...

Stop the initial expansion of the first accordion with JavaScript on page load

I have a simple accordion created using only pure javascript without jQuery and Pure CSS. Everything is functioning correctly, but the problem I am facing is that the first accordion is automatically expanded when the page loads. I have tried various metho ...

Change the position of a div by clicking on different content menu buttons to make it go up

I have implemented move up and move down buttons in my context menu for multiple div drops. However, I am facing an issue with moving the div down after clicking the move down button. Here is the code snippet that I am currently using: $(".propertyClass" ...

Arrange a div beneath another div that is positioned absolutely

Within my code, I have a div with the property of absolute positioning referred to as "abs". Right after this div, there is another div called "footer" which does not have any specified position value assigned to it. Even though I've experimented with ...

Refresh data after modal is closed in AngularJS

-->html code <button type="button" class="btn btn-primary" ng-click="platformAppConfigurationCreate()"> <span class="fa fa-plus"></span> <span class="hidden-xs hidden-sm"> Create </span> </button> --> C ...

How can I use Jquery and Json to retrieve trending words specific to WOEID on the Twitter API?

I want to fetch a list of trending topics from Ireland using Jquery. When I try the following code, it works perfectly: <script> $(document).ready(function() { $.ajax({ url:'http://api.twitter.com/1/trends/current.json?callback=?', ...

Using Ionic with React to smoothly scroll to a selected item in a list

Ionic Scroll To Specific List Item covers Ionic + Angular. However, the solution provided is tailored to AngularJS. Now, I have a similar question but related to Ionic + React: Assuming a layout like this: <IonContent> <IonList> <Io ...

Is there a way to rearrange the tabs so that the first tab is at

Is there a way for me to align with the others without being stuck below #first_tab in the code? I'm having trouble figuring it out on this website: Your assistance would be greatly appreciated! Thank you in advance! CSS Code: #first_tab { ...

What potential factors could lead to an MUI Snackbar failing to produce the accurate class names?

I am facing an issue with displaying notifications on my Gatsby blog whenever the service worker updates. I am using a MUI Snackbar toast for this purpose. However, sometimes the styling of the toast is not applied correctly and it ends up looking like thi ...

Each time the web animation is utilized, it gets faster and faster

As part of an assignment, I am working on creating an interactive book that can be controlled by the arrow keys and smoothly comes to a stop when no key is being pressed. However, I have noticed that with each arrow key press, the animation speeds up. Bel ...

Is there a way to trigger javascript on Amazon once the "Next Page" button is clicked?

My Greasemonkey script is designed to run on Amazon's search results page. However, I've noticed that when the "Next Page" button is clicked and new results are dynamically loaded, my script only executes once after the initial page load. Here&a ...

Button component in React JS fails to appear on iPhones

After building a website using reactjs, I encountered an issue where the landing page's begin button is not displaying correctly on iPhones. The website works fine on all other devices, but on iPhones, the button is barely visible - with only a faint ...

Step-by-step instructions on setting up a feature where clicking on a vacant area will automatically hide the block

Is there a way to create a functionality where clicking on an empty space will close a specific block? Here is the link to view the code on codesandbox <template> <div> <div class="wrapper"></div> </div> &l ...