Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何调用Javascript方法(超出范围?)_Javascript_Jquery_Asp.net - Fatal编程技术网

如何调用Javascript方法(超出范围?)

如何调用Javascript方法(超出范围?),javascript,jquery,asp.net,Javascript,Jquery,Asp.net,我正在使用。很好,但是我需要从jQuery对话框以外的地方访问它的一个javascript方法。以下是我要访问的代码段: TSC.Timeout.Timeout.prototype = { // THE METHOD I WANT TO CALL: _resetTimeout() _resetTimeout: function (e) { // modify timeout to do jquery dialog if (typeof jQuery

我正在使用。很好,但是我需要从jQuery对话框以外的地方访问它的一个javascript方法。以下是我要访问的代码段:

TSC.Timeout.Timeout.prototype =
{
    // THE METHOD I WANT TO CALL: _resetTimeout()
    _resetTimeout: function (e) {
        // modify timeout to do jquery dialog
        if (typeof jQuery.ui == 'undefined')
            $get(this._clientId).style.display = 'none';

        clearTimeout(this._timerAboutToTimeout);
        clearTimeout(this._timerTimeout);
        clearTimeout(this._timerCountDown);

        this._showAboutToTimeoutDelegate = Function.createDelegate(this, this.showAboutToTimeout);
        this._timerAboutToTimeout = setTimeout(this._showAboutToTimeoutDelegate, this._aboutToTimeoutMinutes * 5 * 1000); //TODO: Change this back to 60
        this._timeoutDelegate = Function.createDelegate(this, this.timeout);
        this._timerTimeout = setTimeout(this._timeoutDelegate, this._timeoutMinutes * 10 * 1000); //TODO: Change this back to 60
    },

    // HOW IT'S BEING CALLED FROM WITHIN THE JS OBJECT:
    initDialog: function (e) {
        // modify timeout to do jquery dialog
        if (typeof jQuery.ui != 'undefined') {
            var tsc = this;
            $("#" + this._clientId).dialog({
                autoOpen: false,
                width: 500,
                resizeable: false,
                bgiframe: true,
                modal: true,
                position: 'center',
                buttons: {
                    "Keep Me Signed In": function () {
                        $(this).dialog('close');
                        CallServer();
                        tsc._resetTimeout();
                    }
                }
            });
        }
    }
}
我似乎无法从控制台使
\u resetTimeout()
工作。调用
TSC.Timeout.Timeout.prototype.\u resetTimeout()产生以下错误:

Uncaught TypeError: Cannot read property 'length' of undefined
TSC.Timeout.Timeout.showAboutToTimeoutWebResource.axd:200
(anonymous function)ScriptResource.axd:47
WebResource.axd:217Uncaught TypeError: Cannot read property 'length' of undefined
TSC.Timeout.Timeout.timeoutWebResource.axd:217
(anonymous function)ScriptResource.axd:47
WebResource.axd:213Uncaught TypeError: Property 'focus' of object [object DOMWindow] is not a function
TSC.Timeout.Timeout.showAboutToTimeoutWebResource.axd:213
(anonymous function)

你知道如何调用该方法吗?

调用
TSC.Timeout.Timeout.prototype.\u resetTimeout()
调用原型上的原始方法-换句话说,在范围中使用no对象

当使用
new
操作符实例化该函数(类)时,用于向新对象添加方法:

var timer = new TSC.Timeout.Timeout();

...

timer._resetTimeout(); // Reset timeout called with "timer" object in scope

通常,名称前的
\uu
表示它是“私有”或内部方法。这意味着该功能是通过其他API提供的,不需要直接调用,可能会产生意想不到的结果。因此,我会检查以确保没有其他方法来完成您需要做的事情(我不知道您是否提供了完整的源代码…。

调用
TSC.Timeout.Timeout.prototype.\u resetTimeout()
调用原型上的原始方法-换句话说,在范围中使用no对象

当使用
new
操作符实例化该函数(类)时,用于向新对象添加方法:

var timer = new TSC.Timeout.Timeout();

...

timer._resetTimeout(); // Reset timeout called with "timer" object in scope
通常,名称前的
\uu
表示它是“私有”或内部方法。这意味着该功能是通过其他API提供的,不需要直接调用,可能会产生意想不到的结果。因此,我会检查以确保没有其他方法来完成您需要做的事情(我不知道您是否提供了完整的源代码…)