By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,728 Members | 1,404 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,728 IT Pros & Developers. It's quick & easy.

Referencing parent window script from within iframe

P: n/a
If we have an iframe loaded from the same domain as the parent document,
how can we (is it possible) to execute a function on the parent
document's page?

e.g.
1) On parent page:
------------------
<script type="text/javascript">
<!-- Hide from w3c validator
function tester()
{
alert('tester');
}
//-->
</script>
2) Then we embed an iframe thus:
--------------------------------
<iframe id="locframe" src="iframepage.html" scrolling="no"
marginwidth="0" marginheight="0" frameborder="0"></iframe>


3) Then within the iframepage.html we have a button:
----------------------------------------------------
<input type="button" value="Execute parent.tester"
onclick="parent.document.tester();" />

Should we be able to execute that function and if so how should it be
referenced?
--
jeremy

Nov 22 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jeremy wrote:
1) On parent page:
------------------
<script type="text/javascript">
<!-- Hide from w3c validator
function tester()
{
alert('tester');
}
//-->
</script>

2) Then we embed an iframe thus:
--------------------------------
<iframe id="locframe" src="iframepage.html" scrolling="no"
marginwidth="0" marginheight="0" frameborder="0"></iframe>

3) Then within the iframepage.html we have a button:
----------------------------------------------------
<input type="button" value="Execute parent.tester"
onclick="parent.document.tester();" />

Should we be able to execute that function and if so how should it be
referenced?
onClick="window.parent.tester()"

--
Bart

Nov 22 '06 #2

P: n/a
In article <11**********************@k70g2000cwa.googlegroups .com>, Bart
Van der Donck says...
Should we be able to execute that function and if so how should it be
referenced?

onClick="window.parent.tester()"


Thanks Bart - really appreciate the help.
--
jeremy
Nov 22 '06 #3

P: n/a
ASM
Jeremy a écrit :
If we have an iframe loaded from the same domain as the parent document,
how can we (is it possible) to execute a function on the parent
document's page?
3) Then within the iframepage.html we have a button:
----------------------------------------------------
<input type="button" value="Execute parent.tester"
onclick="parent.document.tester();" />
onclick="parent.tester();"
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Nov 22 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.