请参阅下面的代码:
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);
};
如何将 popup_window 变量传递给回调函数?
答案 0 :(得分:1)
将this.cb(popup_window);
更改为cb(popup_window);
答案 1 :(得分:1)
var prepare = function(cb) {
var popup_window = window.open("my_url");
cb(popup_window);
};
答案 2 :(得分:0)
将this.cb()
替换为cb()