I'm trying to call a Javascript function in an iframe, but nothing I've tried will work in Firefox? Here's what I have:
--------------------------
----------
----------
----------
--
PARENT: parent.html
--------------------------
----------
----------
----------
--
<html>
<head>
<title>Parent</title>
<script>
function callHelloWorld() {
// None of the following attempts worked
//
// document.getElementById('c
hild').hel
loWorld();
// document.getElementById('c
hild').doc
ument.hell
oWorld();
// window.frames['child'].hel
loWorld();
// document.frames['child'].d
ocument.ca
llHelloWor
ld();
}
</script>
</head>
<body onclick="callHelloWorld()"
>
<iframe id="child" src="child.html" width="200" height="200"></iframe>
</body>
</html>
--------------------------
----------
----------
----------
--
IFRAME: child.html
--------------------------
----------
----------
----------
--
<html>
<head>
<title>Child Frame</title>
<script>
function helloWorld() {
alert('Hello, world.');
}
</script>
</head>
<body>
This is the child frame.
</body>
</html>
Start Free Trial