IE 8 iframe border

Terry picture Terry · Oct 26, 2009 · Viewed 36.4k times · Source

There is a border showing on an iframe and I can't get rid of it.

IE 6 and 7 work as intended with a little JavaScript:

function test(){
    var iframe = document.getElementById('frame2');
    iframe.contentWindow.document.body.style.backgroundColor = "#a31d1d";
    iframe.contentWindow.document.body.style.border = "#a31d1d";
    iframe.contentWindow.document.body.style.outlineColor = "#a31d1d";
}

But the border remains visible in IE 8.

Answer

Assaf Feldman picture Assaf Feldman · May 6, 2010

Add following attributes to iframe tag:

marginheight="0" marginwidth="0" frameborder="0"