.contents()in the frame returns the document inside the frame. So you are looking for:
var frame = document.getElementById('myframe');
var c = frame.contentDocument || frame.contentWindow.document;
Note. This will not work if the frame has a different origin.
The rest of the code:
var inner_wp = c.getElementsByClassName('inner-wp');
for (var i=0; i<inner_wp.length; i++) {
inner_wp[i].style.margin = '0';
}
Rob w source
share