var wpage =require('webpage').create();
wpage.onClosing=function(str){}
JavaScript
示例
var wpage =require('webpage').create();
wpage.onClosing=function(str){
console.log("page is closed");}
wpage.open('http://localhost/tasks/closing.html',function(status){
console.log(status);
wpage.close();});