Chrome bug: iframe rendering lines on screen when scrolling up

10,210

Solution 1

Removing the background-color:

body {
...
background-color: #fff; 
}

in the CSS of the HTML document which is rendered into the iFrame did solve the issue in my case.

Solution 2

After one full day trying to solve this bug I can confirm that there's another workaround and it's probably an "easier" one.

In my case these solutions didn't work. In fact, applying them to the examples in the issue tracker of chrome (look for them here http://code.google.com/p/chromium/issues/detail?id=143354 ) didn't actually solve the problem. (PS: the problem is usually based on using the scrollbar and SOMETIMES in using the mouse scrolling).

Therefore I did some searches for services the worked and guess what:
Visual Website optimizer didn't have this problem
and they are indeed using and iframe, good job guys!

So, what solution did they use?
They used a fixed height. (yup!)

So, take the example in the chrome issue 143354 (the one with the red background, ok?) and change the code from

<html>
<body style="background-color:red">
<p>This is outside the iframe</p>
<iframe width="80%" height="50%" frameborder="0" src="./page2.html"></iframe>
</body>
</html>

to

<html>
<body style="background-color:red">
<p>This is outside the iframe</p>
<iframe width="80%" height="50%"  src="./page2.html" style="margin: 0px !important; padding: 0px !important; height: 286px; "></iframe>
</body>
</html>

This will solve the problem of red lines.

To fix my webapp I needed to calculate the height on every window resize, put those margin/padding , and avoiding relative positioning on the iframe, nothing more.

Hope it helped (It almost drew me out of my mind to solve it)

Solution 3

Still same problem here using Windows 7 and chrome 22.0.1229.94 except white lines appear when scrolling down, not scrolling up. I've tried all solutions proposed but nothing seems to fix it. Setting -webkit-margin-after and -webkit-margin-before make lines disappear when scrolling down but now it appear when scrolling up. In chrome group forum, they say it should be fixed in 23 series but who knows...

Finally, can find a workaround (not so cool but works) inspired by some read.

Here it is:

$(document).ready(function(){
                //to fix scrolling bug in iframe for chrome (issue: http://code.google.com/p/chromium/issues/detail?id=140447)
                if(/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())) {
                    var ibody = document.getElementsByTagName('body')[0];           
                    window.onscroll = function(e) { 
                        ibody.style.visibility='hidden';
                        ibody.offsetHeight; 
                        ibody.style.visibility='visible';
                    }
                }
});

Solution 4

Had the same issue. Resolved by setting position style to relative:

<iframe ... style="position: relative"></iframe>

Solution 5

The issue causing these visual anomalies has been confirmed fixed in the latest canary build of chrome (>= 25.0.1365.1 canary), so hopefully the chrome stable channel should have the fix fairly soon.

Share:
10,210
afrotaint
Author by

afrotaint

Updated on June 17, 2022

Comments