JavaScript回调函数问题

时间:2011-09-21 06:16:03

标签: javascript

请参阅下面的代码:

        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 变量传递给回调函数?

3 个答案:

答案 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()