0

I'm now trying to do the screen capture at client side. Since I've used "imagegrabscreen()" function. I've found that it can capture screen on server side only. I try to find the new function and found that only capture screen at client side but store it on client as well. I got some temporary idea that I will use screen capture at client side and use javascript to call the ftp function via batch and transfer those image files to a centralized server. (There need to keep all screen capture files in the same place.)

If any idea please advise.

Thanks in advance

graphicdivine
  • 10,937
  • 7
  • 33
  • 59
Sathapanic Sriprom
  • 355
  • 2
  • 8
  • 15
  • 2
    possible duplicate of [How to take a screen shot of a web page?](http://stackoverflow.com/questions/701798/how-to-take-a-screen-shot-of-a-web-page) –  Jan 23 '12 at 19:17
  • 7
    Thankfully, no. Think about that for just one moment and consider the security risk it would pose to the world. – Brian Roach Jan 23 '12 at 19:20
  • 1
    See duplicate question: [Website screenshots using PHP](http://stackoverflow.com/questions/757675/website-screenshots-using-php) – calebds Jan 23 '12 at 19:22
  • 1
    @BrianRoach: It is possible to get a screenshot of the browser window using JS. See my answer. What are the security threats? It follows the same "Same Origin" policy as an XHR, you can only get screenshots of code sent from your own server – Ruan Mendes Jan 23 '12 at 19:27
  • 1
    @JuanMendes - the OP didn't say "current page displayed in browser", he said "screen"; in my world, a browser tab is not a "screen". I'm guessing you can derive the security issues from there :) – Brian Roach Jan 23 '12 at 19:33
  • possible duplicate of [How can I generate a screenshot of a webpage using a server-side script?](http://stackoverflow.com/questions/713938/how-can-i-generate-a-screenshot-of-a-webpage-using-a-server-side-script) – rpetrich Jan 23 '12 at 22:00
  • My screen need to get the user's gesture (from touch screen events) and that's why I try to capture whole browser's screen. I'm not sure that the HTML element from DOM is contains the gesture. Please kindly advice. – Sathapanic Sriprom Jan 24 '12 at 02:11
  • @BrianRoach: My previous comment was incorrect. Drawing on the canvas does not follow all the "Same Origin" rules. There's a bug with iframes, therefore, you must be running firefox with chrome privileges for a screenshot to work. http://mxr.mozilla.org/mozilla/source/content/canvas/src/nsCanvasRenderingContext2D.cpp#2352 – Ruan Mendes Jan 27 '12 at 19:43

2 Answers2

1

This is not possible using any of the technologies that you describe, unless by JavaScript you mean calling some ActiveX, Browser Plugin, Java, or some real executable code that you've installed on the client machine.

You need to first install something on the client machine that integrates into the user's web browser and provides an interface through JavaScript.

Marcus Adams
  • 53,009
  • 9
  • 91
  • 143
0

If you are OK with Firefox, see this answer: take screen shot using only js in firefox extension

<canvas id='my-canvas'></canvas>
<script> 
var canvas = document.getElementById('my-canvas');
var ctx = canvas.getContext("2D");
// Draw the window at the top left of canvas, width=100, height=200, white background
ctx.drawWindow(window, 0,0, 100, 200, "rgb(255,255,255)");
// Open another window with the thumbnail as an image
open(canvas.toDataURL("image/png"));
</script>

Your canvas will contain a screenshot of the window and you can easily sent that image to the server using Ajax since the call to canvas.toDataUrl() returns the Base64 encoded image.

This feature is only available for code running with Chrome privileges https://developer.mozilla.org/en/Drawing_Graphics_with_Canvas#Rendering_Web_Content_Into_A_Canvas

Here's why http://mxr.mozilla.org/mozilla/source/content/canvas/src/nsCanvasRenderingContext2D.cpp#2352

Community
  • 1
  • 1
Ruan Mendes
  • 90,375
  • 31
  • 153
  • 217