Click here to Skip to main content
15,906,645 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello -

I'm new to this phantomjs and would like to incorporate it into my web app for a user to be able to click a button and it takes a screen shot of their web page for them to open later? Is this possible I've been searching for a few days now and either I can run the phantomjs from the console great but dont know exactly what to do or how to do it from the browser? I created a very simple index page to see if i can use phantomjs and execute my test.js but nothing happens. Any help would be so greatly appreciated.

Thanks

Heres the code:

HTML
<!DOCTYPE html>
<html>

<head> <title> Phantom </title>

<style>
 #change_me {
 position: absolute;
 top: 100px;
 left: 400px;
 font: 24px arial;}
 #move_up #move_down #color #disappear {
 padding: 5px;}
</style>

<script src="scripts/jquery1.9.1.js"></script>
<script src="scripts/test.js"> </script>

</head>
<body>

 <button id="move_up">Move Up</button>
 <button id="move_down">Move Down</button>
 <button id="color">Change Color</button>
 <button id="disappear">Disappear/Re-appear</button>

 <button onClick="myFunction()" id="phantom">PDF</button>

<div id="change_me">Make Me Do Stuff!</div>

<script>
$(document).ready(function() 
{
  $("#move_up").click( function() 
  {
  $("#change_me").animate({top:30},200);
  });//end move_up

  $("#move_down").click( function() {
  $("div").animate({top:500},2000);
  });//end move_down

  $("#color").click( function() {
  $("#change_me").css("color", "Red");
  });//end color

  $("#disappear").click( function() {
  $("#change_me").toggle("slow");
});//end disappear


});//end doc ready

console.log("hi");
</script>
<script>
function myFunction()
{
alert("PDF Image saved");
}
</script>


</body>
</html>
Posted

1 solution

The question makes no sense at all. PhantomJS is not a JavaScript library like jQuery. It is compiled into binary code (http://phantomjs.org/build.html[^]), so, naturally, it cannot be used on the client side at all.

The purposes of this product are completely different:
http://phantomjs.org/[^],
https://github.com/ariya/phantomjs/wiki[^].

Of course, I can imagine using it on the server side for whatever purposes, but it takes us too far from your original question.

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900