- 文件系统模块
- 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
广告