0
我正在使用PhantomJS來運行JavaScript。有一個函數phantom.exit()
接受退出代碼作爲第一個參數。從另一個函數調用時,phantom.exit(-1)不起作用
下面是它如何工作?
var page = require("webpage").create(),
$ = require("jquery")
page.open("http://127.0.0.1:8081/", function (status) {
var title = page.evaluate(function() {
return $("title").text()
})
phantom.exit(-1)
})
返回的退出代碼爲-1或255的預期。
我的問題是,當我的函數被調用時,我需要退出腳本。我的功能包含phantom.exit(-1)
。
var page = require("webpage").create(),
$ = require("jquery")
function foo() {
phantom.exit(-1)
}
page.open("http://127.0.0.1:8081/", function (status) {
var title = page.evaluate(function() {
return $("title").text()
})
foo()
phantom.exit()
})
問題是,phantom.exit(-1)
這是在foo()
功能不被調用和退出代碼爲0
有一個變通方法在我的函數來檢查返回值,並手動調用phantom.exit()
,但它並不像我想它...任何幫助非常感謝!
PhantomJS的版本是什麼? – abele
它是1.7。最新的。 – daGrevis