Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 781739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:16:45+00:00 2026-05-14T20:16:45+00:00

Is there an easy way to set a callback function to a new window

  • 0

Is there an easy way to set a “callback” function to a new window that is opened in javascript? I’d like to run a function of the parent from the new window, but I want the parent to be able to set the name of this particular function (so it shouldn’t be hardcoded in the new windows page).

For example in the parent I have:

function DoSomething { alert('Something'); }
...
<input type="button" onClick="OpenNewWindow(linktonewwindow,DoSomething);" />

And in the child window I want to:

<input type="button" onClick="RunCallbackFunction();" />

The question is how to create this OpenNewWindow and RunCallbackFunction functions. I though about sending the function’s name as a query parameter to the new window (where the server side script generates the appropriate function calls in the generated child’s HTML), which works, but I was thinking whether there is another, or better way to accomplish this, maybe something that doesn’t even require server side tinkering.

Pure javascript, server side solutions and jQuery (or other frameworks) are all welcomed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T20:16:45+00:00Added an answer on May 14, 2026 at 8:16 pm

    Updated for comments: If you’re opening your window via window.open() then in your child page you can set a function in the child to just be a reference pointing to a parent function, so have this in the child page:

    var RunCallbackFunction = function() { }; //reference holder only
    

    Then in your parent (opener), set that function when that child window loads, like this:

    //random function you want to call
    function myFunc() { alert("I'm a function in the parent window"); }
    
    //to actually open the window..
    var win = window.open("window.html");
    win.onload = function() { win.RunCallbackFunction = myFunc; };
    

    This assigns the function in your parent to now be the target of that child…and you can point each child to a different function if you wish, they’re all independent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 441k
  • Answers 441k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I don't know if there's a standard way to do… May 15, 2026 at 5:42 pm
  • Editorial Team
    Editorial Team added an answer I'd use some mailing library - maybe Swiftmailer. Programming it… May 15, 2026 at 5:42 pm
  • Editorial Team
    Editorial Team added an answer the simple answer is YES you can. you can give… May 15, 2026 at 5:42 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.