English 中文(简体)
在节点.js - javascript 中设置时间间隔
原标题:setTimeout in node.js - javascript

这里我有一个3 number i+j+k 的代码, 但我要知道如何配置服务器文件来使用 SetTimeout 功能... 是否有限制?

所以,这是我的代码:

索引.jade

!!! 5
html
  head
    title Test
  body
    form(name= form1 , method= post , action=  )
      label(for= 1 )
      input#1(type= text , name= 1 )
      label(for= 2 )
      input#2(type= text , name= 2 )
      label(for= 3 )
      input#3(type= text , name= 3 )
      input(name= submit , type= button , value= submit ) 
    span #{result}

应用( a.js)

var express = require( express );
        app = express.createServer();

app.configure(function(){
    app.set( views , __dirname +  /views );
    app.set( view engine ,  jade );
    app.set("view options", { layout: false });
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(__dirname +  /public ));
});
app.use(express.bodyParser());
    app.get( / , function(req, res){
        var result;
    res.render( index , {result:   });
});


    app.post( / , function(req, res){
      var i = req.param( 1 , 0);
      i = parseInt(i);
      var j = req.param( 2 , 0);
          j = parseInt(j);

      var k = req.param( 3 , 0);
         k = parseInt(k);

      var r = i+j+k;
      res.render( index , {result:r});

    });
app.listen(3010);

如何屏蔽用户动作( 点击、 双击、 右击), 并给他显示文本“ 您可以做任何动作 ” 。 在前 5 秒后, 用户可以做动作, 但在 60 秒后, 无法再做任何动作... 我可以用 setTimout 函数还是怎么做??

为我的英语感到抱歉

最佳回答

您不能在服务器一侧这样做。 您必须插入客户端的笔记本, 以屏蔽交互作用, 并在 5 秒后再次解开它 。

在客户方面这样做的代码 会是这样的:

// this code should be executed when the client receives a message from the server.
var overlay = document.getElementById("your-element-id");
overlay.style.visibility = "visible";

window.setTimeout(function () {
    overlay.style.visibility = "hidden";
}, 5000);

You should take the following steps to achieve what you want:
1. The user loads the page.
2. The user receives a message from the server, stating that he is being synchronized
3. Then either after a specified time or after another message from the server you unblock the user
4. Finally you start the game

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签