а почему у меня работает?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
window.onload = function() {
document.getElementsByTagName('a')[0].onclick = function() {
var iframe = document.getElementsByTagName('iframe')[0];
var d = iframe.contentDocument ? iframe.contentDocument
: iframe.contentWindow.document;
alert( d.body.firstChild.nodeValue );
return false;
}
}
</script>
</head>
<body>
<iframe src="2.html"></iframe>
<a href="#">click</a>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>title</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
asd
</body>
</html>