- 檔案系統模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 系統模組
- PhantomJS - 屬性
- Web 伺服器模組
- PhantomJS - 屬性
- PhantomJS - 方法
- 其他
- 命令列介面
- PhantomJS - 螢幕捕獲
- PhantomJS - 頁面自動化
- PhantomJS - 網路監視
- PhantomJS - 測試
- PhantomJS - REPL
- PhantomJS - 示例
- PhantomJS 有用資源
- PhantomJS - 快速指南
- PhantomJS - 有用資源
- PhantomJS - 討論
PhantomJS - onConfirm()
當頁面中呼叫帶 ok /cancel 的確認資訊時,將呼叫此回撥。其對回撥的返回值為 true 或 false,true 對應於確認框中單擊的 ok,false 對應於單擊的 cancel。
語法
其語法如下:
wpage.onConfirm = function(msg) {};
示例
以下示例顯示了 onConfirm() 方法的使用。
var wpage = require('webpage').create();
wpage.onConfirm = function(msg) {
console.log(msg);
}
wpage.open('https:///tasks/confirn.html', function(status) {
console.log(status);
phantom.exit();
});
confirm.html
<html>
<body>
<script>
window.confirmationValue = confirm("Press a button!");
</script>
</body>
</html>
上述程式生成以下 輸出。
Press a button! Success
phantomjs_webpage_module_events_callbacks.htm
廣告