Use try/catch
to catch that security error :
function ChangeColor() {
try {
myFrame.contentDocument.body.style.backgroundColor = 'green';
} catch(e) {
alert('You cannot modify a document on a different domain!');
}
}