如何使用node.js获取屏幕分辨率 [英] How to get screen resolution with node.js
本文介绍了如何使用node.js获取屏幕分辨率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要使用node.js获取屏幕分辨率,但以下代码不起作用。
I need get screen resolution with node.js, but the following code don't work.
var w = screen.width;
var h = screen.height;
这也无效。
var w = window.screen.width;
var h = window.screen.height;
有人知道如何使用node.js获取屏幕分辨率?
谢谢。
Someone know how to get screen resolution with node.js ? Thank you.
推荐答案
我解决了 phantomJS
。
安装 phantomJS
:
sudo apt-get install phantomjs
创建app.js文件: p>
Create app.js file:
var w = screen.width;
var h = screen.height;
console.log(w+"x"+h);
phantom.exit();
执行:
phantomjs app.js
返回:
1366x768
这篇关于如何使用node.js获取屏幕分辨率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文