468,483 Members | 2,688 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,483 developers. It's quick & easy.

Problems with Calling a Function from iframe

1
Hello Everyone,

Please help the novice in java scripting. I'm trying to call changeSection (x, y) function from the iframe. Basically I have my code and my iframe tag in index.html. Then I click on the menu button and it loads an iframe with the name art.html. I have a function that defines which page the user is currently on and writes the name of it.

Here what I have in index.html

[HTML]<script type="text/javascript">

function changeSection (x, y) {
current=x;
document.getElementById("pagetitle").innerHTML = y;
}
</script>

<body>
<li> <a href = "art.html" target="window"> <img id="art" src="images/art.gif" onClick="changeSection('art', 'art')" /></a></li>

<div id="pagetitle">
</div>

<iframe src="slideshow.swf" id="window" name="window" frameborder="0" width="800px" height="490px" scrolling="no">
</iframe>
</body>
[/HTML]
Then in art.html I have some links that have to work with the same function changeSection(x, y). But it doesn't see it.

So I write:

[HTML]
<script type="text/javascript">
parent.changeSection (x, y);
</script>

<body>
<a href="123.html"><img id="123" src="images/art/123.jpg" widht="79px" height="79px" alt="123"
onClick="changeSection('123', 'Performance')"/></a>
</body>[/HTML]

Please help! I can't figure it out!
Oct 19 '07 #1
1 1427
gits
5,390 Expert Mod 4TB
hi ...

welcome to TSDN ...

have a close look at your fixed code, that places the call to the parent's function in a function itself, you could also place the parent-ref directly to the onclick-call:

[HTML]
<script type="text/javascript">
function call_change_section(x, y) {
parent.changeSection (x, y);
}
</script>

<body>
<a href="123.html">
<img id="123" src="images/art/123.jpg" widht="79px" height="79px" alt="123" onclick="call_change_section('123', 'Performance')"/>
</a>
</body>
[/HTML]
kind regards
Oct 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Dan Popa | last post: by
5 posts views Thread by mike | last post: by
13 posts views Thread by ukrbend | last post: by
3 posts views Thread by PCgeek | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.