1
我在頁面內有一個腳本標記,但它沒有運行。它只是呈現。我怎樣才能得到幻影「執行」我的網頁?
我有以下代碼:
var phantom = require('phantom');
phantom.create(function(ph,error) {
c = callback;
ph.createPage(function(page,err) {
page.setContent(output);
callback = c;
setTimeout(function() {
page.evaluate(function() {
return document.getElementsByTagName('html')[0].innerHTML;
}, function(html) {
callback(html);
});
}, 5000);
});
});
我如何告訴幻影「裝入」 /「運行」的頁面,使頁面上運行腳本? (我不希望使用page.open)
此外,內容"<p>Page <strong>1</strong> content.</p><button id=\"page1_button\">button</button><script>document.getElementsByTagName('p').innerHTML = 'test';</script>"
對,問題是我不想在我想要在本地呈現文檔時發出請求。有沒有另一種方式? – Nonconformist
如果你絕對必須做任何你想做的事情,你可以使用網絡服務器模塊。 – kanzure