Advertisement

10.11.2005 at 04:21PM PDT, ID: 21591743
[x]
Attachment Details

How do you call a Javascript function in an iframe?

Asked by jasonr11 in Miscellaneous Web Development

Tags: , , ,

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('child').helloWorld();
    // document.getElementById('child').document.helloWorld();
    // window.frames['child'].helloWorld();
    // document.frames['child'].document.callHelloWorld();
}
</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
[+][-]10.11.2005 at 06:59PM PDT, ID: 15065745

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2005 at 07:03PM PDT, ID: 15065757

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2005 at 08:32PM PDT, ID: 15065984

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.11.2005 at 08:49PM PDT, ID: 15066029

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2005 at 09:57PM PDT, ID: 15066258

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2005 at 07:59AM PDT, ID: 15069503

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Miscellaneous Web Development
Tags: iframe, javascript, function, call
Sign Up Now!
Solution Provided By: bglodde
Participating Experts: 1
Solution Grade: A
 
 
[+][-]10.12.2005 at 09:56AM PDT, ID: 15070646

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32