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();
});

上述程序生成以下输出

失败

在上面的例子中,我们使用 onLoadStarted 事件来停止页面加载。由于页面已停止,我们得到的状态为失败。

phantomjs_webpage_module_methods.html