Click here to Skip to main content
15,879,184 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i have a html page with iframe having login input n password and submit button...... now how i determine on my parents page that the submit of iframe is called or the submit on parent page is called ......
Posted

Hello, please follow this sample:

Parent page:

XML
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>

      <script type="text/javascript">

          function alert_me() {
              alert('hello this is parent');

          }
      </script>
 </head>
 <body>
 <iframe src="iframePage.aspx" width="800px" height="600px">
 </iframe>
 </body>
</html>



Iframe Page( Child Page):

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">

    <script type="text/javascript">

        function ClickMe() {
            parent.alert_me('hello there!');
        }
    </script>
 </head>
    <body>
        <br/>
        <br/>
        <input type="button" value="Click me" id="button_click" onclick="ClickMe()"/>
    </body>
</html>
 
Share this answer
 
This looks not too honest to me. If both sources are yours, avoid using iframe. But look around on the following urls...

First consult the "same origin policy": http://code.google.com/p/browsersec/wiki/Part2#Same-origin_policy_for_DOM_access[^].

Than read the really exhaustive tutorial here: http://stackoverflow.com/questions/3076414/ways-to-circumvent-the-same-origin-policy[^], and maybe watch this screencast too. http://alexsexton.com/blog/2011/06/breaking-the-cross-domain-barrier-screencast/[^]
 
Share this answer
 
Comments
vaibhavraidwivedi 19-Dec-12 8:50am    
both on same domain

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