Sunday, May 19, 2024
 Popular · Latest · Hot · Upcoming
87
rated 0 times [  91] [ 4]  / answers: 1 / hits: 45374  / 9 Years ago, wed, december 16, 2015, 12:00:00

Example page source:



<!DOCTYPE html>
<html lang=en>
<head>
<meta charset=UTF-8>
<meta name=viewport content=width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no>
<title>Page</title>
</head>
<body>
<div class=main style=height: 100%;>
<div class=header style=height: 100px; background-color: green;></div>

<iframe src=http://www.wikipedia.com
style=height: 200px; width: 100%; border: none;></iframe>

<div class=footer style=height: 100px; background-color: green;></div>
</div>
</body>
</html>


The problem is, that height of 200px from the IFrames inline style is ignored on mobile safari:



enter



Also I'd like to change the height of the IFrame dynamically via vanilla JavaScript which is not working at all with the following code:



document.getElementsByTagName('iframe')[0].style.height = 100px


The value of the height style is changed correctly according to the dev tools but it's simply ignored since the actually rendered height of the IFrame doesn't change.



This only seems to be a problem in mobile Safari and is working as expected on the latest versions of desktop Safari, Firefox, Chrome, Androids WebView etc.



Testpage: http://devpublic.blob.core.windows.net/scriptstest/index.html



Ps.: I tested this with various devices on browserstack and also took the screenshots there since I don't have no actual iDevice at hand.


More From » ios

 Answers
9

It looks like this: How to get an IFrame to be responsive in iOS Safari?



iFrames have an issue on iOS only, so you have to adapt your iframe to it.



You can put a div wrapping the iframe, set css on the iframe and, what worked for me, was to add: put the attribute scrolling='no'.



Wishing you luck.


[#64041] Monday, December 14, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaydon

Total Points: 651
Total Questions: 103
Total Answers: 100

Location: Norway
Member since Mon, May 23, 2022
2 Years ago
;