node-phantom icon indicating copy to clipboard operation
node-phantom copied to clipboard

page.evaluate(func, callback, param). param can not be a Function.

Open damphat opened this issue 12 years ago • 2 comments

params can be Function in phatomjs, but node-phantom currently does not support it.

function getBodyHTML(){
    return document.body.innerHTML
}

var phantom = require('node-phantom')
phantom.create(function(_, ph){
    ph.createPage(function(_, page){
        page.open('http://example.com', function(_, status){
            console.log(status);
            page.evaluate(function(aFunc) {
                return aFunc()     // FAILED HERE !!!!!!!
            }, function(_, ret){
                console.log(ret)
            }, getBodyHTML)
        })
    })
})

I currently solve the problem by func.toString() then eval. But I would like node-phantom can support function serialize.

damphat avatar Aug 29 '13 10:08 damphat

+1

Laboratory avatar Apr 08 '14 17:04 Laboratory

+1

n-sham avatar Sep 01 '16 09:09 n-sham