- 檔案系統模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 系統模組
- PhantomJS - 屬性
- Web 伺服器模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 雜項
- 命令列介面
- PhantomJS - 螢幕捕獲
- PhantomJS - 頁面自動化
- PhantomJS - 網路監控
- PhantomJS - 測試
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 有用資源
- PhantomJS - 快速指南
- PhantomJS - 有用資源
- PhantomJS - 討論
PhantomJS - onConsoleMessage()
當網頁中使用控制檯訊息時,會使用此回撥。此回撥使用以下三個引數。
- 訊息
- 行號
- 源識別符號
語法
其語法如下 −
page.onConsoleMessage = function(msg, lineNum, sourceId) {};
示例
var wpage = require('webpage').create();
wpage.onConsoleMessage = function(msg) {
console.log('CONSOLE Message: ' + msg );
};
wpage.open('https:///tasks/test.html', function(status) {
var script1 = "function(){ console.log('hello world');}";
var value = wpage.evaluate(script1);
phantom.exit();
});
上述程式生成以下輸出。
CONSOLE Message: hello world
phantomjs_webpage_module_events_callbacks.htm
廣告