SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Zealot DocDave's Avatar
    Join Date
    Sep 2004
    Location
    Milwaukee, WI, USA
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Calling a function from a pop-up

    First let me say I have very little javascript experience. I have a post form page in which this function resides. From this page I am calling a pop-up with a button to call a function back in the main window. I have found information on this already, but when I try it, no dice. Some help? Here's what I got...

    Code:
    function reset(n) {
    ...some function stuff...
    }
    The function works when I click the button in the Main window with the following.
    Code:
    <input type="button" value="Update" onClick="reset('one')">
    But it does not work when I click this button in the Pop-Up window.
    Code:
    <input type="button" value="Update" onClick="window.opener.reset('one')">
    What am I missing here.
    .:Blog:.

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    81
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For the sake of clarity, let's call the original window page A and the popup, page B. The reset() function is on page A, right? Are you opening page B with window.open()? What happens when you click the button on page B? What error message(s) do you get?

    Have you tried window.parent rather than window.opener?
    I'm available for hire! - www.deftdevelopment.com

  3. #3
    SitePoint Zealot DocDave's Avatar
    Join Date
    Sep 2004
    Location
    Milwaukee, WI, USA
    Posts
    113
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes the function is on page A.

    Yes the pop-up, page B, is being opened with window.open(), from with-in a javascript function.

    I get no response when I click the button on page B.

    I just tried the window.parent per your suggestion, and nadda.

    What ended up working was: top.opener.parent. I saw i in another part of the code I was using as a reference to the page, and gave it a try.

    Thanks for your suggestions, they led me in the right direction.
    .:Blog:.


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
  •