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
Tareq
1,9962 gold badges28 silver badges57 bronze badges
3 Answers 3
var prepare = function(cb) {
var popup_window = window.open("my_url");
cb(popup_window);
};
answered Sep 21, 2011 at 6:24
Mike
1,0421 gold badge8 silver badges14 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
Change this.cb(popup_window); to cb(popup_window);
answered Sep 21, 2011 at 6:21
xdazz
161k38 gold badges255 silver badges278 bronze badges
Comments
Replace this.cb() with cb()
Mp0int
18.8k16 gold badges88 silver badges119 bronze badges
Comments
lang-js
this.cb(popup_window);. What do you really mean? Note: whythis.cb()? I wouldn't expect that to work, whilecb()should work.