473,789 Members | 3,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling a function from the iframe to the parent

132 New Member
Helo everybody,
I'm having a problem with a functioncall from my iFrame.

I have a page which houses an iframe. The contents of that is being generated in the script and has the following output:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type='text/javascript'>
  4. function edt(idx)
  5. {
  6. alert(idx);
  7. parent.test();
  8. }
  9. </script>
  10. </head>
  11. <body>
  12. <table cellpadding='2' cellspacing='2' border='1'><tr><td>ID</td><td>date</td><td>client</td><td>program</td><td>start time</td><td>stop time</td><td>overtime</td><td>extra</td><td>cost</td><td>&nbsp;</td></tr><tr><td>0</td><td></td><td>none</td><td>test2</td><td>none</td><td>none</td><td>TBD</td><td></td><td>TBD</td><td><input type='button' value='EDIT' onclick='edt(0)'</td></tr>
  13. </table>
  14. </body>
  15. </html>
  16.  
I want to be able to edit the data by pushing the EDIT button which calls for the edt(index)-function. In that function as a way of testing I added an alert. Then I call on the test() function on the parent-page just again as a way of testing. That testfunction just displays an alertbox with Test in it.

So what happens when I push the button? Well I get the first alertbox with the indexnumber in it. So that's working well, but then when I try to call on the test function on the parent window I get "This property or method is not supported by this object". So clearly there is something wrong when he wants to access the functions on my parent page.

I've been looking all over the net and everywhere I keep finding the same answer parent.function () should do the trick except here it doesn't.

Might be worth mentioning that the functions are all in an external .js-file.

If anybody has the magic solution, please let me know :-)

Thanks!
Jun 16 '09 #1
9 2324
acoder
16,027 Recognized Expert Moderator MVP
Can you show the code for the test() function?

Note that you haven't closed the input button properly.
Jun 16 '09 #2
Cainnech
132 New Member
@acoder
Expand|Select|Wrap|Line Numbers
  1. function test()
  2. {
  3. alert('Test');
  4. }
  5.  
@acoder
You're right, thanks for pointing that out.
Jun 16 '09 #3
acoder
16,027 Recognized Expert Moderator MVP
Hmm, that should work. For good measure, I tested your code and it worked fine:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <script type="text/javascript">
  4. function test()
  5. {
  6. alert('Test');
  7. }
  8. </script>
  9. </head>
  10. <body>
  11. Test<iframe src="iframetest.html">
  12. </body>
  13. </html>
Jun 16 '09 #4
Cainnech
132 New Member
@acoder
At first I thought the problem was due to the fact that I was generating the content of the iframe in the script rather than just loading a page. But I made a testpage to test everything and on that page it's doing it perfectly.

I copied and pasted it into my big page and there it fails again...

I'm going crazy on this one :-(
Jun 16 '09 #5
Cainnech
132 New Member
Aaahhhh,

Already one step closer...

What I didn't mention in my post is that my parent is actually an HTML Application and not an ordinary html-page.

So first of all I had to put the application="ye s" inside my iframetags. But still it doesn't work...

So appearantly the hta doesn't work with parent.
Jun 16 '09 #6
Cainnech
132 New Member
@Cainnech
Strange but when I changed it in my big project then it works. So problem solved!
Me happy ;-)
Jun 16 '09 #7
acoder
16,027 Recognized Expert Moderator MVP
Good for you! What exactly did you change?
Jun 16 '09 #8
Cainnech
132 New Member
I added the application="ye s" to my iframe.

And I've should have know it because I used it before...
Jun 16 '09 #9
acoder
16,027 Recognized Expert Moderator MVP
Simple once you know. Thanks for posting.
Jun 16 '09 #10

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

Similar topics

3
1745
by: Dennis M. Marks | last post by:
I have a function that displays a list extracted from a table using document.write. In the displayed list I want to have a link that will call the same function but display the list in reverse. Click HERE to reverse A B C When HERE is clicked the page will redisplay as
2
4558
by: Randell D. | last post by:
Folks, I have got this working before, in part with some help from this ng but I never really understood how I got it working... and last time, I was using it via a popup window as opposed to an IFRAME. I've got several months of javascript under my belt and can resolve most things without errors in my Mozilla Javascript Console, but this one just does not do it for me. This is the picture:
5
4643
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:
18
43566
by: Chris Ianson | last post by:
Hi geniuses (or is that genii, or genies) The challenge is as above really. I have a page with an iframe in it, and need to call a JS function in the *parent* page, *from* inside the iframe. (It's for Google Maps, but I won't bore you with the complexities of that, as it doesn't affect the question). Mochas kudos to anyone able to solve this widdle.
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10199
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9020
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6768
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4092
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 we have to send another system
2
3697
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.