BTW I don't have any control over the webpage, so no code can be added to it.
I think the problem is that document.write needs context.
try oldDocumentWrite.call(document, arts);
Came up with the following code to override document.write() function. Log can be printed but the part calling original function is not working (marked by <---). Any thought?
----------------------------------------------------------------------------------
var page = require('webpage').create(),
system = require('system'),
url;
url = system.args[1];
page.onConsoleMessage = function(msg) {
console.log(msg);
};
page.onInitialized = function() {
page.evaluate(function() {
var oldDocumentWrite = document.write;
document.write = function(arg) {
console.log('document.write() called: '+arg);
return oldDocumentWrite(arg); <------ NOT WORKING
};
});
};
page.open(url, function (status) {
if (status !== 'success') {
console.log('FAIL to load the address');
}
console.log(page.content);
phantom.exit();
});
----------------------------------------------------------------------------------
--
You received this message because you are subscribed to a topic in the Google Groups "phantomjs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phantomjs/6Z3yYG46Lk8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phantomjs+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/phantomjs.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to phantomjs+...@googlegroups.com.