Click here to Skip to main content
15,887,336 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all
I have an iframe in my page. now i want get an object or call a java function in parent from iframe.

how can i do? is possible?!
Posted
Updated 11-Sep-11 19:02pm
v2
Comments
Sergey Alexandrovich Kryukov 12-Sep-11 2:31am    
Your tag is "JavaScript". Why do you ask about Java?
--SA

1 solution

If I understood your question correctly, you want to call a Parent Page method from IFrame in the same page. YES you can.
Let say you have below Structure

[mainpage markup]
   [main page JS ]
       function TestMethod()
          {
          }
[main page JS ]
        [iframe id="myiframe"]
         [/iframe] 
[mainpage markup]

Then you can call the TestMethod as below

document.getElementById('myiframe').contentWindow.TestMethod();


contentWindow will return you parent container. Hope this helps !!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900