- 檔案系統模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 系統模組
- PhantomJS - 屬性
- Web 伺服器模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 其他
- 命令列介面
- PhantomJS - 螢幕截圖
- PhantomJS - 頁面自動化
- PhantomJS - 網路監控
- PhantomJS - 測試
- PhantomJS - REPL
- PhantomJS - 範例
- PhantomJS 有用資源
- PhantomJS - 快速指南
- PhantomJS - 有用資源
- PhantomJS - 討論
PhantomJS - onFilePicker()
此 onFilePicker () 回撥用於上傳檔案。當用戶想要上傳檔案時,會呼叫此回撥。
語法
其語法如下 -
page.onFilePicker = function(oldFile) { }
示例
var wpage = require('webpage').create();
wpage.onFilePicker = function(oldFile) {
console.log('Entering file picker callback');
console.log(oldFile);
}
wpage.open("https:///tasks/file.html", function(status) {
console.log(status);
wpage.evaluate(function() {
var fileUp = document.querySelector("#fileToUpload");
var ev = document.createEvent("MouseEvents");
ev.initEvent("click", true, true);
fileUp.dispatchEvent(ev);
});
});
以上程式會生成以下 輸出。
Success Entering file picker callback
phantomjs_webpage_module_events_callbacks.htm
廣告