PhantomJS - stop()



stop() 方法有助于停止页面加载。

语法

其语法如下 −

var wpage = require('webpage').create(); 
wpage.stop(); 

示例

var wpage = require('webpage').create(); 
wpage.onLoadStarted = function() { 
   wpage.stop(); 
} 
wpage.open('http://localhost/tasks/wopen2.html', function(status) { 
   console.log(status);  
   phantom.exit(); 
});

以上程序生成以下输出

Fail

在以上示例中,我们使用 onLoadStarted 事件来停止页面继续加载。由于该页面已停止加载,因此我们获得的状态为失败。

phantomjs_webpage_module_methods.htm
广告