Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome bug: iframe rendering lines on screen when scrolling up

bug here: https://groups.google.com/a/chromium.org/forum/?fromgroups#!topic/chromium-bugs/eUfzp3UJDwo%5B1-25%5D

just encountered this problem, streaking up my screen on chrome, but not on firefox, or IE. anyone on a mac seen this?

like image 311
afrotaint Avatar asked Aug 18 '12 18:08

afrotaint


4 Answers

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.

like image 80
Michael Avatar answered Sep 25 '22 22:09

Michael


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)

like image 27
Andrea Grassi Avatar answered Sep 23 '22 22:09

Andrea Grassi


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';
                    }
                }
});
like image 26
A. Wolff Avatar answered Sep 24 '22 22:09

A. Wolff


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

<iframe ... style="position: relative"></iframe>
like image 44
Pavlo Neiman Avatar answered Sep 24 '22 22:09

Pavlo Neiman