This is similar to this question, although a bit broader.
I’m just opening these pages locally, and they sit in the same folder.
index.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<title>TestIndex</title>
<script type="text/javascript">
function init()
{
alert("child.childvar: " + child.childvar); //works in FF, IE, not Chrome
alert("frames['child'].childvar: " + frames['child'].childvar); //works in FF, IE, not Chrome
alert("document.getElementById('child').contentWindow['childvar']: " + document.getElementById('child').contentWindow['childvar']); //works in FF, IE, not Chrome
child.childfunc(); //works in FF, IE, not Chrome
frames['child'].childfunc(); //works in FF, IE, not Chrome
document.getElementById('child').contentWindow['childfunc()']; //doesn't work in anything
}
var parentvar = 7;
function parentfunc()
{
alert("In parentfunc");
}
window.onload = init;
</script>
</head>
<body>
<iframe id="child" name="child" src="child.html">Your browser does not support iframes</iframe>
</body>
</html>
child.html:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>TestChild</title>
<script type="text/javascript">
function init()
{
alert("parent.parentvar: " + parent.parentvar); //works in FF, IE, not Chrome
parent.parentfunc(); //works in FF, IE, not Chrome
}
var childvar = 5;
function childfunc()
{
alert("In childfunc");
}
window.onload = init;
</script>
</head>
<body>
</body>
</html>
I can’t seem to achieve any communication at all between a page and its iframe’s content in chrome. I did read the answers to the question I linked to, but I don’t really know what userscripts/content scripts are, so I don’t know how relevant that questions was to mine.
I guess my actual question is: how the hell do I get values from an iframe’d page into the parent page!?
Apparently javascript inter-frame communication doesn’t work when on the local file system. Put the files on a server and it will likely function as expected.