继续时钟时间页面的时候在JavaScript后刷新(continue clock time afte

2019-10-21 03:34发布

我使用JavaScript来把定时器在我的网页。 当按下启动按钮,时钟开始时间戳。

所有的东西都没有任何错误正常工作。

代码

initialize_timer: function() {
    this.project_m2o = new project_timesheet.FieldMany2One(this, {model: this.project_timesheet_model , classname: "pt_input_project pt_required", label: "Select a project", id_for_input: "project_id"});
    this.project_m2o.on("change:value", this, function() {
        var project = [this.project_m2o.get('value'), this.project_m2o.$input.val()];
        this.project_timesheet_db.set_current_timer_activity({project_id: project});
        this.set_project_model();

现在,每当页面刷新武功的时钟应该继续,但再次与初始化00:00

指导我来对付它!

Answer 1:

当你在一个cookie或本地存储启动定时器存储系统时间。 每一次你的网页加载后,你可以阅读以前的系统启动时间,并适当地初始化时钟。

如果时间必须不容易被篡改,那么你就需要在每次从服务器提供的时间的时间来存储您的服务器为每个用户,并置于开始时间为用户在页面中。



文章来源: continue clock time after page gets refreshed in javascript