I have a page with an iframe, and a Javascript function that I need to get the contents of the iframe - what I mean by that is, the text from the list.html file that's in the iframe. It's actually a list of numbers (no formatting) but I'm happy to take it as a text string and go from there... it could be a .txt file but I heard at one point that .html would work better. Trouble is, I can't work out how to access the contents of the iframe from the script. Here's what I have. I'm trying to keep it as simple as possible so I can build around it when I get it working.
-
<html>
-
-
<head>
-
<script language="JavaScript">
-
function getList() {
-
var list = document.getElementById('myFrame').innerHtml;
-
alert(list);
-
}
-
</script>
-
</head>
-
-
<body>
-
<iframe name="myFrame" id="myFrame" src="list.html"><iframe>
-
<a href="javascript:getList()">Get List</a>
-
</body>
-
-
</html>
-
I'm really clueless here - it's the first time I've tried to do any input in Javascript other than forms. I have done extensive googling and experimented by myself, but everything I try gets me either no alert at all, or an alert that just reads "undefined". I've tried 'getElementById', 'window.frames("myFrame")', every combination of document.body and window.document.body imaginable... is there something obvious I'm missing?