[英]How to set viewport size in PhantomJS from Chutzpah
How I can set viewport size in PhantomJS? 如何在PhantomJS中设置视口大小? I tried to set it using window.callPhantom
: 我试图使用window.callPhantom
进行设置:
window.callPhantom('page.viewportSize = { width: 480, height: 800 };')
as suggested here: https://github.com/mmanela/chutzpah/issues/355 , but this doesn't seem to work, because later window.innerHeight
still shows 300px (this is the default height of viewport in PhantomJS) 如此处建议的那样: https : //github.com/mmanela/chutzpah/issues/355 ,但这似乎不起作用,因为稍后的window.innerHeight
仍显示300px(这是PhantomJS中视口的默认高度)
Chutzpah supports you calling phantom to change size but it requires you pass the arguments a little bit differently. Chutzpah支持您调用phantom来更改大小,但是它要求您通过一些不同的方式传递参数。 Try: 尝试:
window.callPhantom(
{
Type:"Eval",
Data: "phantom.pagesize(100,200);"
});
I am missing documentation on this which I will correct soon. 我缺少有关此问题的文档,我会尽快纠正。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.