Skip to main content
Better title, little fixes
Source Link
Artjom B.
  • 62k
  • 26
  • 137
  • 236

phantomJS How to execute page.render in evaluateinside page.evaluate?

iI do want to render my page and exit phantomJSPhantomJS in the evaluate function, because iI want to trigger it when a specific event is fired. I've

I've tried something like this:

 page.evaluate(page, function (page, phantom) {   //do some stuff on my page   //i want to execute this in an eventhandler of my page though thats not the problem   page.render('imgName.png');   page.render('pdfName.pdf');   phantom.exit();  }, page, phantom); 

This doesn't work in my example, because page.render seems to be undefined. Maybe there is a serializer for the arguments which is not serializing functions of the obj?

Is this even possible? Anyone knowsDoes anyone know a solution for my issue?

I know iI could set a while loop in my evaluate function and prevent its termination and do this page render stuff outside afterwards. I dontdon't like this though.

phantomJS execute page.render in evaluate

i do want to render my page and exit phantomJS in the evaluate function because i want to trigger it when a specific event is fired. I've tried something like this:

 page.evaluate(page, function (page, phantom) {   //do some stuff on my page   //i want to execute this in an eventhandler of my page though thats not the problem   page.render('imgName.png');   page.render('pdfName.pdf');   phantom.exit();  }, page, phantom); 

This doesn't work in my example, because page.render seems to be undefined. Maybe there is a serializer for the arguments which is not serializing functions of the obj?

Is this even possible? Anyone knows a solution for my issue?

I know i could set a while loop in my evaluate function and prevent its termination and do this page render stuff outside afterwards. I dont like this though.

How to execute page.render inside page.evaluate?

I do want to render my page and exit PhantomJS in the evaluate function, because I want to trigger it when a specific event is fired.

I've tried something like this:

page.evaluate(page, function (page, phantom) { //do some stuff on my page //i want to execute this in an eventhandler of my page though thats not the problem page.render('imgName.png'); page.render('pdfName.pdf'); phantom.exit(); }, page, phantom); 

This doesn't work in my example, because page.render seems to be undefined. Maybe there is a serializer for the arguments which is not serializing functions of the obj?

Is this even possible? Does anyone know a solution for my issue?

I know I could set a while loop in my evaluate function and prevent its termination and do this page render stuff outside afterwards. I don't like this though.

Source Link
JuHwon
  • 2.1k
  • 2
  • 34
  • 56

phantomJS execute page.render in evaluate

i do want to render my page and exit phantomJS in the evaluate function because i want to trigger it when a specific event is fired. I've tried something like this:

 page.evaluate(page, function (page, phantom) { //do some stuff on my page //i want to execute this in an eventhandler of my page though thats not the problem page.render('imgName.png'); page.render('pdfName.pdf'); phantom.exit(); }, page, phantom); 

This doesn't work in my example, because page.render seems to be undefined. Maybe there is a serializer for the arguments which is not serializing functions of the obj?

Is this even possible? Anyone knows a solution for my issue?

I know i could set a while loop in my evaluate function and prevent its termination and do this page render stuff outside afterwards. I dont like this though.