PhantomJS - scrollPosition 屬性



這包含指示滾動位置的物件。它給出左右。你可以更改左右的值來改變頁面滾動位置。或者,只讀取值來了解頁面滾動位置。

語法

其語法如下 −

var wpage = require('webpage').create() 
wpage.scrollPosition; 

示例

讓我們舉個例子來理解使用scrollPosition 屬性。

var wpage = require('webpage').create(); 
wpage.open('https:///tasks/page1.html', function (status) {
   console.log(JSON.stringify(wpage.scrollPosition)); 
   wpage.scrollPosition = { 
      top:500, 
      left:30   
   } 
   console.log(JSON.stringify(wpage.scrollPosition)); 
   phantom.exit(); 
});

以上程式生成以下輸出

{"left":0,"top":0} 
{"left":30,"top":500} 
phantomjs_webpage_module_properties.htm
廣告
© . All rights reserved.