我想在点击鼠标时运行某些代码。我发现大多数帖子只在鼠标单击表单内部或在某个对象内部时执行代码。我希望代码在任何地方运行 单击鼠标。这甚至可能吗?
答案 0 :(得分:3)
您可以使用//Load the request module
var request = require('request');
//Configure and make the request
request({
url: 'https://www.googleapis.com/urlshortener/v1/url?key=XXXXXXXXX',
method: 'POST',
headers: { //We can define headers too
'Content-Type': 'application/json'
},
data: {
'longUrl': 'http://www.myverylongurl.com'
}
}, function(error, response, body){
if(error) {
console.log(error);
} else {
console.log(response.statusCode, response.body);
}
});
api并检查鼠标左右按钮。这是一个使用计时器进行轮询的示例
"errors": [{ "domain": "global", "reason": "required", "message": "Required", "locationType": "parameter”, “location": "resource.longUrl"
}]