473,480 Members | 1,663 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Problems with Calling a Function from iframe

1 New Member
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 1599
gits
5,390 Recognized Expert Moderator Expert
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

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

Similar topics

0
2067
by: Dan Popa | last post by:
Check out the following 2 links: http://www.batisdev.com/admin/test_1images.asp http://www.batisdev.com/admin/test_2images.asp First page contain 4 IFRAMES and 1 IMG tags. Second page contain 4...
12
9744
by: Javier | last post by:
Hello, I'm very new in this forum and as I have the following problem, the website is in http://new.vanara.com ----------------------------------------------------------------------------...
4
3604
by: nec | last post by:
Hi, I'm having trouble calling a function thats located in a iFrame from the parent. Shortly, i can't figure out the location in DOM. In IE it works fine with a simple line of...
9
3266
by: Ragnorack67 | last post by:
.... <div id=work>hello</div> .... <IFRAME id="thisframe" src="./something.htm"></IFRAME> <script>
5
4607
by: mike | last post by:
If I have a document like: <script> function mike_test() {alert('hi');} </script> <iframe src="blank.html" id="my_iframe1"> </iframe> and in blank.html I have:
13
6657
by: ukrbend | last post by:
I'm new to Javascript and to html and am trying to make the following code snippet work but it doesn't. It refuses to call the getPage() function and I always get a 404 error. I know the code is...
9
11138
by: aatcbbtccctc | last post by:
Hi folks I've googled for an answer to this, with no success. Can someone please jump in, and put me out of my misery! (I'm sure it's quite simple) I have an invisible IFRAME, and a visible...
3
4462
by: PCgeek | last post by:
sorry moved this over to javascript forum, didn't mean to post 2x! Hi guys, I'm trying to put the finishing touches on my website and could really use some help on this particular issue. My page...
0
7034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
6732
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4472
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2990
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
174
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.