Get DOM element's actual width using jsdom

戏子无情 提交于 2019-12-21 11:30:37

问题


I wonder if I could get a DOM element's actual width and coordinates, as I can get using .clientWidth / .offsetWidth from within the browser.

Does jsdom has browser rendering capabilities in order to get this data?

If not, how can I get this within node.js server?

Thanks!


回答1:


JSDOM is strictly a DOM API emulation library. It does not attempt to actually render a document, which is necessary to compute element size and position.

You may want to look at PhantomJS. It is a full WebKit renderer with a JavaScript API. It is entirely separate from node, so you either need to write a utility script using Phantom's API, or use a npm module that lets you control Phantom from node.



来源:https://stackoverflow.com/questions/19914111/get-dom-elements-actual-width-using-jsdom

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!