如何调用Javascript原型函数?

如何调用Javascript原型函数?,javascript,function-prototypes,Javascript,Function Prototypes,这是要调用的Javascript代码 该函数从第6阶段发出警报,我将完全重建以使其恢复活动:) //警报(在标题中) 功能警报(总计){ 当前页面=1; this.last_page=Math.ceil(总计/4); if(this.current\u page==this.last\u page){ $('alert-next-button')。类名称='alert-next-inactive'; } } 这是来自DivX Stage6的原型函数: Alerts.prototype.next

这是要调用的Javascript代码 该函数从第6阶段发出警报,我将完全重建以使其恢复活动:)

//警报(在标题中)
功能警报(总计){
当前页面=1;
this.last_page=Math.ceil(总计/4);
if(this.current\u page==this.last\u page){
$('alert-next-button')。类名称='alert-next-inactive';
}
}
这是来自DivX Stage6的原型函数:

Alerts.prototype.next = function () {
    if (this.current_page == this.last_page) {
        return;
    }
    new Effect.BlindUp('alerts-' + this.current_page, {
        scaleFrom:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    new Effect.BlindDown('alerts-' + (this.current_page + 1), {
        scaleTo:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    this.current_page++;
    if (this.current_page > 1) {
        $('alert-prev-button').className = 'alert-prev';
    }
    if (this.current_page == this.last_page) {
        $('alert-next-button').className = 'alert-next-inactive';
    }
}
第二个原型功能:

Alerts.prototype.previous = function () {
    if (this.current_page == 1) {
        return;
    }
    new Effect.BlindUp('alerts-' + this.current_page, {
        scaleFrom:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    new Effect.BlindDown('alerts-' + (this.current_page - 1), {
        scaleTo:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    this.current_page--;
    if (this.current_page == 1) {
        $('alert-prev-button').className = 'alert-prev-inactive';
    }
    if (this.current_page < this.last_page) {
        $('alert-next-button').className = 'alert-next';
    }
}
Alerts.prototype.nameYourFunction = function(total) {
    this.current_page = 1;
    this.last_page = Math.ceil(total / 4);
    if (this.current_page == this.last_page) {
        $('alert-next-button').className = 'alert-next-inactive';
    }

};
Alerts.prototype.previous=函数(){
if(this.current_page==1){
返回;
}
新效果。BlindUp('alerts-'+this.current_页{
缩放范围:80,
持续时间:0.4,
队列:{
位置:'结束',
范围:'alerts'
}
});
新效果。盲降('alerts-'+(this.current_page-1){
比例:80,
持续时间:0.4,
队列:{
位置:'结束',
范围:'alerts'
}
});
这是当前页面--;
if(this.current_page==1){
$('alert-prev-button')。类名称='alert-prev-inactive';
}
如果(此当前页面<此最后页面){
$('alert-next-button')。类名称='alert-next';
}
}
我需要这个函数的HTML代码。 这是逆向工程:=)

这是第六阶段的照片

我已经全部测试过了,但我没有解决方案


希望有人能帮助我。

不确定您是在尝试定义原型函数,还是调用原型函数:

要创建原型功能,请执行以下操作:

Alerts.prototype.previous = function () {
    if (this.current_page == 1) {
        return;
    }
    new Effect.BlindUp('alerts-' + this.current_page, {
        scaleFrom:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    new Effect.BlindDown('alerts-' + (this.current_page - 1), {
        scaleTo:80,
        duration:0.4,
        queue:{
            position:'end',
            scope:'alerts'
        }
    });
    this.current_page--;
    if (this.current_page == 1) {
        $('alert-prev-button').className = 'alert-prev-inactive';
    }
    if (this.current_page < this.last_page) {
        $('alert-next-button').className = 'alert-next';
    }
}
Alerts.prototype.nameYourFunction = function(total) {
    this.current_page = 1;
    this.last_page = Math.ceil(total / 4);
    if (this.current_page == this.last_page) {
        $('alert-next-button').className = 'alert-next-inactive';
    }

};
nameYourFunction
替换为您想调用的任何函数

然后你可以这样称呼它:

Alerts.nameYourFunction(2);
或者给您添加到问题中的问题打电话:

Alerts.next();

嗯。。。嗯<代码>变量a=新警报(5);a、 next()??

您认为这里的原型函数是什么?请描述您正在尝试做什么。您正在尝试使用方法创建函数或持久对象吗?您对
这个
的使用通常与一个对象/方法相关联,但我看不到任何上下文。如果您只是想要一个函数,那么您可以将
current_page
last_page
更改为局部变量,并将其作为一个普通函数使用。您是在谈论Prototype.js而不是Prototype继承吗?