简体   繁体   English

如何调用Javascript原型函数?

[英]How I can Call Javascript prototype functions?

This is the Javascript code to call the Function Alerts it is from Stage6 that I will fully rebuild to bring it back to live :) 这是从Stage6调用功能警报的Javascript代码,我将对其进行完全重建以使其恢复活动:)

// Alerts (in the header)
    function Alerts(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';
        }
    }

This is the Prototype Function it is from DivX Stage6: 这是来自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';
    }
}

The Second Prototype function: 第二个原型函数:

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';
    }
}

I need the HTML Code for this functions. 我需要此功能的HTML代码。 It is reverse engineering :=) 这是逆向工程:=)

Here is the picture from Stage 6 http://img10.imageshack.us/img10/1733/83630697.png 这是第六阶段的图片http://img10.imageshack.us/img10/1733/83630697.png

I have all tested but I have no solution. 我都进行了测试,但没有解决方案。

Hope someone can help me out. 希望有人可以帮助我。

Not sure if you are trying to define a prototype function, or call one: 不知道您是要定义原型函数还是调用一个原型函数:

To make a prototype function: 制作原型功能:

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';
    }

};

replace nameYourFunction to whatever you would like to call it nameYourFunction替换为您要调用的nameYourFunction

then you'll be able to call it like so: 那么您就可以像这样调用它:

Alerts.nameYourFunction(2);

OR to call the one you added to your question: 或致电您添加到问题中的一个:

Alerts.next();

mmm... mmm.... var a = new Alerts(5); a.next() mmm ... mmm .... var a = new Alerts(5); a.next() var a = new Alerts(5); a.next() ???? var a = new Alerts(5); a.next() ????

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在JavaScript原型之外调用函数? - How can I call a function outside of the prototype in JavaScript? 如何用JavaScript制作原型? - How can I make a prototype of a prototype in JavaScript? 如何通过 JavaScript 调用 PHP 函数? - How can I call PHP functions by JavaScript? 在javascript中如何在另一个原型方法中调用一个原型方法? - In javascript how can I call one prototype method in another prototype method? Javascript多个原型函数 - 如何从另一个调用 - Javascript multiple prototype functions - how to call one from another 我如何在一个JavaScript文件中拥有多个document.observe(dom:loaded…)函数? (原型) - How can I have multiple document.observe(dom:loaded …) functions inside one javascript file? (prototype) 使用JavaScript揭示原型模式,我如何命名原型中包含的函数? - Using the JavaScript revealing prototype pattern, how can I namespace functions contained within prototypes? 如何通过Javascript调用Phonegap中的本机函数? - How can I call native functions in Phonegap through Javascript? 如何在外部调用javascript库函数? - How can I call javascript library functions externally? 如何依次调用多个异步javascript函数? - How can I call multiple asynchronous javascript functions in sequence?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM