有关节点js的html按钮onclick的信息

时间:2016-12-05 10:45:02

标签: javascript html node.js

这是我的代码:

file.html

<html>
 <head>
 </head>
 <body>
  <form>
   <input type="button" value="hello1" onClick="window.location.reload()"/>
   <input type="button" value="hello2" onClick="window.location.reload()" />
  </form>
 </body>

这是我的file.js

var http=require('http');
var fs = require('fs');
var server = http.createServer(function(req, res){
    displayForm(res);
});

function displayForm(res) {
    fs.readFile('file.html', 'utf8', function (err, data) {
            res.writeHead(200, {'Content-Type': 'text/html'});
            res.write(data);
            res.end();
    });
 }

 server.listen(port, 'ip');
 console.log("Server running at http://ip:port/");

我的问题是:是否有可能在http.createServer(函数(req,res){...})中区分点击了什么按钮?这个问题可能看起来很愚蠢,因为两个按钮都做同样的事情,但我需要做一件事。谢谢大家

0 个答案:

没有答案
相关问题