Обрати внимание на contentWindow:
main.html:
Код:
<html>
<head>
<title>Frame test</title>
<script>
function test() {
var iframeE = document.getElementById('foo');
var spanE = iframeE.contentWindow.document.getElementById('bar');
spanE.appendChild(iframeE.contentWindow.document.createTextNode('Buzz'));
}
</script>
</head>
<body>
<iframe id="foo" src="frame.html" width="200" height="200"></iframe>
<button onClick="test()">Test</button>
</body>
</html>
frame.html:
Код:
<html>
<head>
<title>iFrame</title>
</head>
<body>
<span id="bar">Bar</span>
</body>
</html>
P.S. Посмотри, какой content-type отдается в заголовках HTTP-ответа. Не путать с content-type в мета-тэгах.