SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member balaji_A's Avatar
    Join Date
    Mar 2004
    Location
    India
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calling parent window function

    Parent window script
    <script language="javascript">
    function show()
    {
    msgwindow = open('Page2.htm','window','width=200,height=200');
    msgWindow.opener = self;
    }
    function func2()
    {
    alert('function called from child window');
    }
    </script>


    In my page2.htm file i have one button. Onclick of the button should invoke the function by name 'funct2()' which is present in the parent window. How do i call a parent window function from child window?

    Thanks.

  2. #2
    SitePoint Guru
    Join Date
    Jun 2004
    Location
    Finland
    Posts
    703
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <script language="JavaScript" type="text/javascript">
    function show()
    {
    msgwindow = window.open('Page2.htm','window','width=200,height=200');
    }
    function func2()
    {
    alert('function called from child window');
    }
    show();
    </script>

    ( To page2.htm: )

    <input type="button" onclick="window.opener.func2()" value="Show funny alert">


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •