0

Please see my code below:

 var callback = function(popup_window) {
 popup_window.close();
 //some more codes here
 };
 var prepare = function(cb) {
 popup_window = window.open("my_url");
 this.cb(popup_window);
 };
 function refresh(){
 prepare(callback);
 };

How can I pass the popup_window variable to the callback function ?

asked Sep 21, 2011 at 6:16
3
  • 3
    You already are passing popup_window to the callback in your code this.cb(popup_window);. What do you really mean? Note: why this.cb()? I wouldn't expect that to work, while cb() should work. Commented Sep 21, 2011 at 6:18
  • what do u actually want to do? Commented Sep 21, 2011 at 6:21
  • I am trying to pass popup_window but this actually not passed to callback function because my window did not closed. I am trying to close the opened window. Commented Sep 21, 2011 at 6:22

3 Answers 3

1
 var prepare = function(cb) {
 var popup_window = window.open("my_url");
 cb(popup_window);
 };
answered Sep 21, 2011 at 6:24
Sign up to request clarification or add additional context in comments.

Comments

1

Change this.cb(popup_window); to cb(popup_window);

answered Sep 21, 2011 at 6:21

Comments

0

Replace this.cb() with cb()

Mp0int
18.8k16 gold badges88 silver badges119 bronze badges
answered Sep 21, 2011 at 6:22

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.