0
我有這段代碼在phantomjs中運行。我不知道爲什麼form.elements一直向我返回null。我在Chrome開發者控制檯上運行了相同的代碼,並獲得了我想要的正確結果。null爲phantomjs中的元素
我很新的JavaScript和一切有關。請說明一下。
var page = require('webpage').create();
page.open('http://www.kayak.com', function (status) {
if (status !== 'success') {
console.log('Unable to access network');
} else {
var form = page.evaluate(function(){
return document.getElementById('searchform');
});
console.log(form.elements[2].value);
}
phantom.exit();
});
謝謝你,澄清了很多 – ssb 2013-02-11 19:33:09