如何在phantomJS中触发window.scrollTo(x,y) [英] How to trigger a window.scrollTo(x, y) in phantomJS

查看:105
本文介绍了如何在phantomJS中触发window.scrollTo(x,y)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打开一个网页,我想触发onLoadFinished回调中的滚动. 但它不起作用.我还尝试了scrollPosition并将计时器设置为发送按键事件. 他们两个都不起作用. 所以寻求帮助.

I open a web page, and I want trigger a scrolling in onLoadFinished callback. but it dose't working. I also tried scrollPosition and set timer to sent key event. Both of them dose't working. So ask for help.

page.onLoadFinished = function() {
    window.scrollTo(0, document.height);
}

page.open('http://www.XXX.com', function (status) {
    if (status !== 'success') {
        console.log('Unable to open weibo.com');
    }
}

推荐答案

如果可以全尺寸打开页面,为什么需要滚动?只需将页面的大小设置为您需要的任何大小即可.

Why would you need scrolling if you could open the page in the whole size? Just set size of the page to be whatever size you need.

这篇关于如何在phantomJS中触发window.scrollTo(x,y)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆