- 檔案系統模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 系統模組
- PhantomJS - 屬性
- Web 伺服器模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 雜項
- 命令列介面
- PhantomJS - 螢幕捕獲
- PhantomJS - 頁面自動化
- PhantomJS - 網路監控
- PhantomJS - 測試
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 實用資源
- PhantomJS - 快速指南
- PhantomJS - 實用資源
- PhantomJS - 討論
PhantomJS - viewportSize 屬性
此屬性允許更改視窗顯示的大小。它包含寬度和高度,你可以根據要求讀取或更改它們。
語法
它的語法如下 −
var wpage = require('webpage').create();
wpage.viewportSize;
示例
我們舉個例子來理解 viewportSize 屬性的用法
var wpage = require('webpage').create();
wpage.open('https:///tasks/page1.html', function (status) {
console.log(JSON.stringify(wpage.viewportSize));
wpage.viewportSize = {
'width' : 800,
'height' : 800
}
console.log(JSON.stringify(wpage.viewportSize));
phantom.exit();
});
上面的程式生成以下 輸出。
{"height":300,"width":400}
{"height":800,"width":800}
phantomjs_webpage_module_properties.htm
廣告