SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member Janne's Avatar
    Join Date
    Jan 2003
    Location
    Cambridge
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    can I call a function from another window?

    say I have a pop-up window, can I call its functions from a completely different browser window??



    anyone know?
    When you can't see the angles no more..no more no more no more.. You're in Trouble..
    ..trouble ..trouble ..trouble


  2. #2
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you open the window yourself. i.e.:

    Code:
       var mywin = window.open(url, "mywin");
       mywin.alert("I'm calling a function in the opened window from the parent.");
    or, once you've opened myWin it could do this:

    Code:
       window.opener.document.alert("Calling a function in the parent window from the opened window.");
    If you want a really cool example of this, go to www.americanhistoryimprints.com and go to the mail order form. In the item #'s boxes to the bottom enter in item numbers like 123, 555, 987, 1054, etc. It will (should) pop up a box that basically runs a script to get the data for that item #, populate the form on the opening window and then close the pop-up. If the item isn't there, it closes the pop-up and does an alert to say it wasn't found. (Try entering 3333333 to get this result.)


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
  •