access javascript function from parent from child iframe?

Is it possible to access a javascript function from an iframe? For example:

Parent.htm
<script language='Javascript'>
function blah() {
  alert("here");
}
</script>

<iframe id='testing' src='content.htm'>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
content.htm

<script language='Javascript'>
parent.blah();
</script>


Note that this does not work.
skiboy825Asked:
Who is Participating?
 
BatalfConnect With a Mentor Commented:
"parent" or "top" is the syntax you should use

parent.blah();

or

top.blah(); // If parent isn't a part of a frameset.

So your could should have worked.

Do you have any variables with the same name as the function?

example:

// THIS DOESN'T WORK
var blah;
function blah(){
    alert('Here');
}

Or do you get any error messages?

Batalf
0
 
KNVB HKSITOCommented:
Which version of IE you are using?
I got NO problem at all.
0
 
thirdCommented:
it is possible as long as the framed page and the parent page belong to the same domain.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.