Using HTML5/Canvas/JavaScript to take in-browser screenshots











up vote
823
down vote

favorite
579












Google's "Report a Bug" or "Feedback Tool" lets you select an area of your browser window to create a screenshot that is submitted with your feedback about a bug.



Google Feedback Tool ScreenshotScreenshot by Jason Small, posted in a duplicate question.



How are they doing this? Google's JavaScript feedback API is loaded from here and their overview of the feedback module will demonstrate the screenshot capability.










share|improve this question




















  • 2




    Elliott Sprehn wrote in a Tweet few days ago: > @CatChen That stackoverflow post is not accurate. Google Feedback's screenshot is done entirely client side. :)
    – Goran Rakic
    Jul 11 '11 at 17:53










  • This seams logical as they want to catch exactly how the user's browser is rendering a page, not how they would render it on the server side using their engine. If you only send the current page DOM to the server it will miss any inconsistencies in how the browser is rendering the HTML. This does not mean Chen's answer is wrong for taking screenshots, it just looks like Google is doing it in a different way.
    – Goran Rakic
    Jul 11 '11 at 18:21












  • Elliott mentioned Jan Kuča today, and I found this link in Jan's tweet: jankuca.tumblr.com/post/7391640769/…
    – Cat Chen
    Jul 12 '11 at 11:28










  • I'll dig into this later and see how it can be done with client-side rendering engine and check if Google's actually do it in that way.
    – Cat Chen
    Jul 12 '11 at 11:30










  • I see use of compareDocumentPosition, getBoxObjectFor, toDataURL, drawImage, tracking padding and things like that. It's thousands of lines of obfuscated code to de-obfuscate and look through though. I'd love to see an open source licensed version of it, I have contacted Elliott Sprehn!
    – Luke Stanley
    Jul 12 '11 at 18:18















up vote
823
down vote

favorite
579












Google's "Report a Bug" or "Feedback Tool" lets you select an area of your browser window to create a screenshot that is submitted with your feedback about a bug.



Google Feedback Tool ScreenshotScreenshot by Jason Small, posted in a duplicate question.



How are they doing this? Google's JavaScript feedback API is loaded from here and their overview of the feedback module will demonstrate the screenshot capability.










share|improve this question




















  • 2




    Elliott Sprehn wrote in a Tweet few days ago: > @CatChen That stackoverflow post is not accurate. Google Feedback's screenshot is done entirely client side. :)
    – Goran Rakic
    Jul 11 '11 at 17:53










  • This seams logical as they want to catch exactly how the user's browser is rendering a page, not how they would render it on the server side using their engine. If you only send the current page DOM to the server it will miss any inconsistencies in how the browser is rendering the HTML. This does not mean Chen's answer is wrong for taking screenshots, it just looks like Google is doing it in a different way.
    – Goran Rakic
    Jul 11 '11 at 18:21












  • Elliott mentioned Jan Kuča today, and I found this link in Jan's tweet: jankuca.tumblr.com/post/7391640769/…
    – Cat Chen
    Jul 12 '11 at 11:28










  • I'll dig into this later and see how it can be done with client-side rendering engine and check if Google's actually do it in that way.
    – Cat Chen
    Jul 12 '11 at 11:30










  • I see use of compareDocumentPosition, getBoxObjectFor, toDataURL, drawImage, tracking padding and things like that. It's thousands of lines of obfuscated code to de-obfuscate and look through though. I'd love to see an open source licensed version of it, I have contacted Elliott Sprehn!
    – Luke Stanley
    Jul 12 '11 at 18:18













up vote
823
down vote

favorite
579









up vote
823
down vote

favorite
579






579





Google's "Report a Bug" or "Feedback Tool" lets you select an area of your browser window to create a screenshot that is submitted with your feedback about a bug.



Google Feedback Tool ScreenshotScreenshot by Jason Small, posted in a duplicate question.



How are they doing this? Google's JavaScript feedback API is loaded from here and their overview of the feedback module will demonstrate the screenshot capability.










share|improve this question















Google's "Report a Bug" or "Feedback Tool" lets you select an area of your browser window to create a screenshot that is submitted with your feedback about a bug.



Google Feedback Tool ScreenshotScreenshot by Jason Small, posted in a duplicate question.



How are they doing this? Google's JavaScript feedback API is loaded from here and their overview of the feedback module will demonstrate the screenshot capability.







javascript html5 canvas screenshot






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Sep 12 '17 at 21:41

























asked Feb 6 '11 at 6:58









joelvh

8,01842319




8,01842319








  • 2




    Elliott Sprehn wrote in a Tweet few days ago: > @CatChen That stackoverflow post is not accurate. Google Feedback's screenshot is done entirely client side. :)
    – Goran Rakic
    Jul 11 '11 at 17:53










  • This seams logical as they want to catch exactly how the user's browser is rendering a page, not how they would render it on the server side using their engine. If you only send the current page DOM to the server it will miss any inconsistencies in how the browser is rendering the HTML. This does not mean Chen's answer is wrong for taking screenshots, it just looks like Google is doing it in a different way.
    – Goran Rakic
    Jul 11 '11 at 18:21












  • Elliott mentioned Jan Kuča today, and I found this link in Jan's tweet: jankuca.tumblr.com/post/7391640769/…
    – Cat Chen
    Jul 12 '11 at 11:28










  • I'll dig into this later and see how it can be done with client-side rendering engine and check if Google's actually do it in that way.
    – Cat Chen
    Jul 12 '11 at 11:30










  • I see use of compareDocumentPosition, getBoxObjectFor, toDataURL, drawImage, tracking padding and things like that. It's thousands of lines of obfuscated code to de-obfuscate and look through though. I'd love to see an open source licensed version of it, I have contacted Elliott Sprehn!
    – Luke Stanley
    Jul 12 '11 at 18:18














  • 2




    Elliott Sprehn wrote in a Tweet few days ago: > @CatChen That stackoverflow post is not accurate. Google Feedback's screenshot is done entirely client side. :)
    – Goran Rakic
    Jul 11 '11 at 17:53










  • This seams logical as they want to catch exactly how the user's browser is rendering a page, not how they would render it on the server side using their engine. If you only send the current page DOM to the server it will miss any inconsistencies in how the browser is rendering the HTML. This does not mean Chen's answer is wrong for taking screenshots, it just looks like Google is doing it in a different way.
    – Goran Rakic
    Jul 11 '11 at 18:21












  • Elliott mentioned Jan Kuča today, and I found this link in Jan's tweet: jankuca.tumblr.com/post/7391640769/…
    – Cat Chen
    Jul 12 '11 at 11:28










  • I'll dig into this later and see how it can be done with client-side rendering engine and check if Google's actually do it in that way.
    – Cat Chen
    Jul 12 '11 at 11:30










  • I see use of compareDocumentPosition, getBoxObjectFor, toDataURL, drawImage, tracking padding and things like that. It's thousands of lines of obfuscated code to de-obfuscate and look through though. I'd love to see an open source licensed version of it, I have contacted Elliott Sprehn!
    – Luke Stanley
    Jul 12 '11 at 18:18








2




2




Elliott Sprehn wrote in a Tweet few days ago: > @CatChen That stackoverflow post is not accurate. Google Feedback's screenshot is done entirely client side. :)
– Goran Rakic
Jul 11 '11 at 17:53




Elliott Sprehn wrote in a Tweet few days ago: > @CatChen That stackoverflow post is not accurate. Google Feedback's screenshot is done entirely client side. :)
– Goran Rakic
Jul 11 '11 at 17:53












This seams logical as they want to catch exactly how the user's browser is rendering a page, not how they would render it on the server side using their engine. If you only send the current page DOM to the server it will miss any inconsistencies in how the browser is rendering the HTML. This does not mean Chen's answer is wrong for taking screenshots, it just looks like Google is doing it in a different way.
– Goran Rakic
Jul 11 '11 at 18:21






This seams logical as they want to catch exactly how the user's browser is rendering a page, not how they would render it on the server side using their engine. If you only send the current page DOM to the server it will miss any inconsistencies in how the browser is rendering the HTML. This does not mean Chen's answer is wrong for taking screenshots, it just looks like Google is doing it in a different way.
– Goran Rakic
Jul 11 '11 at 18:21














Elliott mentioned Jan Kuča today, and I found this link in Jan's tweet: jankuca.tumblr.com/post/7391640769/…
– Cat Chen
Jul 12 '11 at 11:28




Elliott mentioned Jan Kuča today, and I found this link in Jan's tweet: jankuca.tumblr.com/post/7391640769/…
– Cat Chen
Jul 12 '11 at 11:28












I'll dig into this later and see how it can be done with client-side rendering engine and check if Google's actually do it in that way.
– Cat Chen
Jul 12 '11 at 11:30




I'll dig into this later and see how it can be done with client-side rendering engine and check if Google's actually do it in that way.
– Cat Chen
Jul 12 '11 at 11:30












I see use of compareDocumentPosition, getBoxObjectFor, toDataURL, drawImage, tracking padding and things like that. It's thousands of lines of obfuscated code to de-obfuscate and look through though. I'd love to see an open source licensed version of it, I have contacted Elliott Sprehn!
– Luke Stanley
Jul 12 '11 at 18:18




I see use of compareDocumentPosition, getBoxObjectFor, toDataURL, drawImage, tracking padding and things like that. It's thousands of lines of obfuscated code to de-obfuscate and look through though. I'd love to see an open source licensed version of it, I have contacted Elliott Sprehn!
– Luke Stanley
Jul 12 '11 at 18:18












3 Answers
3






active

oldest

votes

















up vote
1033
down vote



accepted
+50










JavaScript can read the DOM and render a fairly accurate representation of that using canvas. I have been working on a script which converts HTML into a canvas image. Decided today to make an implementation of it into sending feedbacks like you described.



The script allows you to create feedback forms which include a screenshot, created on the client's browser, along with the form. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.



It does not require any rendering from the server, as the whole image is created on the client's browser. The HTML2Canvas script itself is still in a very experimental state, as it does not parse nearly as much of the CSS3 attributes I would want it to, nor does it have any support to load CORS images even if a proxy was available.



Still quite limited browser compatibility (not because more couldn't be supported, just haven't had time to make it more cross browser supported).



For more information, have a look at the examples here:



http://hertzen.com/experiments/jsfeedback/



edit
The html2canvas script is now available separately here and some examples here.



edit 2
Another confirmation that Google uses a very similar method (in fact, based on the documentation, the only major difference is their async method of traversing/drawing) can be found in this presentation by Elliott Sprehn from the Google Feedback team:
http://www.elliottsprehn.com/preso/fluentconf/






share|improve this answer



















  • 1




    Very cool, Sikuli or Selenium might be good for going to different sites, comparing a shot of the site from the testing tool to your html2canvas.js rendered image in terms of pixel similarity! Wonder if you could automatically traverse parts of the DOM with a very simple formula solver to find how to parse alternate data sources for browsers where getBoundingClientRect isn't available. I'd probably use this if it was open source, was considering toying with it myself. Nice work Niklas!
    – Luke Stanley
    Jul 15 '11 at 19:25






  • 1




    @Luke Stanley I will most likely throw the source up on github this weekend,still some minor clean ups and changes I want to do before then, as well as get rid of the unnecessary jQuery dependancy it currently has.
    – Niklas
    Jul 15 '11 at 19:43






  • 36




    The source code is now available at github.com/niklasvh/html2canvas, some examples of the script in use html2canvas.hertzen.com there. Still lot of bugs to fix, so I wouldn't recommend using the script in a live environment yet.
    – Niklas
    Jul 16 '11 at 1:42






  • 1




    @trusktr I've replied to the question at github.com/niklasvh/html2canvas/issues/56
    – Niklas
    Feb 20 '12 at 15:32






  • 1




    any solution to make it work for SVG will be a great help. It does not work with highcharts.com
    – Jagdeep
    Dec 25 '12 at 6:26


















up vote
57
down vote













Your web app can now take a 'native' screenshot of the client's entire desktop using getUserMedia():



Have a look at this example:



https://www.webrtc-experiment.com/Pluginfree-Screen-Sharing/



The client will have to be using chrome (for now) and will need to enable screen capture support under chrome://flags.






share|improve this answer



















  • 11




    Can you tell me please why you want to screenshot my whole desktop? I used until now Chrome, now I'm thinking to uninstall it, even if I'm satisfied with it's possibilities. I don't like that as a End-user, someone making a screenshot of my desktop!
    – XMight
    Oct 4 '14 at 12:55






  • 2




    i can't find any demos of just taking a screenshot -- everything is all about screen-sharing. will have to try it.
    – jwl
    Oct 16 '14 at 14:56






  • 7




    @XMight, you can choose whether to allow this by toggling the screen capture support flag.
    – Matt Sinclair
    Nov 10 '14 at 15:20






  • 9




    @XMight Please don't think like this. Web browsers should be able to do a lot of things, but unfortunately they are not consistent with their implementations. It is absolutely ok, if a browser has such functionality, as long as the user is being asked. No one will be able to make a screenshot without your attention. But too much fear results in bad implementations, like the clipboard API, which has been disabled altogether, instead creating confirmation dialogs, like for webcams, mics, screenshot capability, etc.
    – StanE
    May 24 '17 at 17:50






  • 3




    This was deprecated and will be removed from the standard according to developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
    – Agustin Cautin
    Feb 16 at 8:10


















up vote
16
down vote













As Niklas mention you can use html2canvas library to make screenshot using js browser . I will develop his answer in this point by provide example of making screenshot using this library (in this question frame):






function report() {
let region = document.querySelector("body"); // whole screen
html2canvas(region, {
onrendered: function(canvas) {
let pngUrl = canvas.toDataURL(); // png in dataURL format
let img = document.querySelector(".screen");
img.src = pngUrl;

// here you can allow user to set bug-region
// and send it with 'pngUrl' to server
},
});
}

.container {
margin-top: 10px;
border: solid 1px black;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div>Screenshot tester</div>
<button onclick="report()">Take screenshot</button>

<div class="container">
<img width="75%" class="screen">
</div>





In report() function in onrendered after getting image as data-uri you can show it to user and allow him to draw "bug region" by mouse and then send screenshot and region coordinates to server.



In this example async/await version was made: with nice makeScreenshot() function.






share|improve this answer



















  • 7




    If you wanna give minus point, leave also comment with explanation
    – Kamil Kiełczewski
    Jul 9 at 8:11










protected by NullPoiиteя Jun 23 '13 at 10:11



Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



Would you like to answer one of these unanswered questions instead?














3 Answers
3






active

oldest

votes








3 Answers
3






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1033
down vote



accepted
+50










JavaScript can read the DOM and render a fairly accurate representation of that using canvas. I have been working on a script which converts HTML into a canvas image. Decided today to make an implementation of it into sending feedbacks like you described.



The script allows you to create feedback forms which include a screenshot, created on the client's browser, along with the form. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.



It does not require any rendering from the server, as the whole image is created on the client's browser. The HTML2Canvas script itself is still in a very experimental state, as it does not parse nearly as much of the CSS3 attributes I would want it to, nor does it have any support to load CORS images even if a proxy was available.



Still quite limited browser compatibility (not because more couldn't be supported, just haven't had time to make it more cross browser supported).



For more information, have a look at the examples here:



http://hertzen.com/experiments/jsfeedback/



edit
The html2canvas script is now available separately here and some examples here.



edit 2
Another confirmation that Google uses a very similar method (in fact, based on the documentation, the only major difference is their async method of traversing/drawing) can be found in this presentation by Elliott Sprehn from the Google Feedback team:
http://www.elliottsprehn.com/preso/fluentconf/






share|improve this answer



















  • 1




    Very cool, Sikuli or Selenium might be good for going to different sites, comparing a shot of the site from the testing tool to your html2canvas.js rendered image in terms of pixel similarity! Wonder if you could automatically traverse parts of the DOM with a very simple formula solver to find how to parse alternate data sources for browsers where getBoundingClientRect isn't available. I'd probably use this if it was open source, was considering toying with it myself. Nice work Niklas!
    – Luke Stanley
    Jul 15 '11 at 19:25






  • 1




    @Luke Stanley I will most likely throw the source up on github this weekend,still some minor clean ups and changes I want to do before then, as well as get rid of the unnecessary jQuery dependancy it currently has.
    – Niklas
    Jul 15 '11 at 19:43






  • 36




    The source code is now available at github.com/niklasvh/html2canvas, some examples of the script in use html2canvas.hertzen.com there. Still lot of bugs to fix, so I wouldn't recommend using the script in a live environment yet.
    – Niklas
    Jul 16 '11 at 1:42






  • 1




    @trusktr I've replied to the question at github.com/niklasvh/html2canvas/issues/56
    – Niklas
    Feb 20 '12 at 15:32






  • 1




    any solution to make it work for SVG will be a great help. It does not work with highcharts.com
    – Jagdeep
    Dec 25 '12 at 6:26















up vote
1033
down vote



accepted
+50










JavaScript can read the DOM and render a fairly accurate representation of that using canvas. I have been working on a script which converts HTML into a canvas image. Decided today to make an implementation of it into sending feedbacks like you described.



The script allows you to create feedback forms which include a screenshot, created on the client's browser, along with the form. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.



It does not require any rendering from the server, as the whole image is created on the client's browser. The HTML2Canvas script itself is still in a very experimental state, as it does not parse nearly as much of the CSS3 attributes I would want it to, nor does it have any support to load CORS images even if a proxy was available.



Still quite limited browser compatibility (not because more couldn't be supported, just haven't had time to make it more cross browser supported).



For more information, have a look at the examples here:



http://hertzen.com/experiments/jsfeedback/



edit
The html2canvas script is now available separately here and some examples here.



edit 2
Another confirmation that Google uses a very similar method (in fact, based on the documentation, the only major difference is their async method of traversing/drawing) can be found in this presentation by Elliott Sprehn from the Google Feedback team:
http://www.elliottsprehn.com/preso/fluentconf/






share|improve this answer



















  • 1




    Very cool, Sikuli or Selenium might be good for going to different sites, comparing a shot of the site from the testing tool to your html2canvas.js rendered image in terms of pixel similarity! Wonder if you could automatically traverse parts of the DOM with a very simple formula solver to find how to parse alternate data sources for browsers where getBoundingClientRect isn't available. I'd probably use this if it was open source, was considering toying with it myself. Nice work Niklas!
    – Luke Stanley
    Jul 15 '11 at 19:25






  • 1




    @Luke Stanley I will most likely throw the source up on github this weekend,still some minor clean ups and changes I want to do before then, as well as get rid of the unnecessary jQuery dependancy it currently has.
    – Niklas
    Jul 15 '11 at 19:43






  • 36




    The source code is now available at github.com/niklasvh/html2canvas, some examples of the script in use html2canvas.hertzen.com there. Still lot of bugs to fix, so I wouldn't recommend using the script in a live environment yet.
    – Niklas
    Jul 16 '11 at 1:42






  • 1




    @trusktr I've replied to the question at github.com/niklasvh/html2canvas/issues/56
    – Niklas
    Feb 20 '12 at 15:32






  • 1




    any solution to make it work for SVG will be a great help. It does not work with highcharts.com
    – Jagdeep
    Dec 25 '12 at 6:26













up vote
1033
down vote



accepted
+50







up vote
1033
down vote



accepted
+50




+50




JavaScript can read the DOM and render a fairly accurate representation of that using canvas. I have been working on a script which converts HTML into a canvas image. Decided today to make an implementation of it into sending feedbacks like you described.



The script allows you to create feedback forms which include a screenshot, created on the client's browser, along with the form. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.



It does not require any rendering from the server, as the whole image is created on the client's browser. The HTML2Canvas script itself is still in a very experimental state, as it does not parse nearly as much of the CSS3 attributes I would want it to, nor does it have any support to load CORS images even if a proxy was available.



Still quite limited browser compatibility (not because more couldn't be supported, just haven't had time to make it more cross browser supported).



For more information, have a look at the examples here:



http://hertzen.com/experiments/jsfeedback/



edit
The html2canvas script is now available separately here and some examples here.



edit 2
Another confirmation that Google uses a very similar method (in fact, based on the documentation, the only major difference is their async method of traversing/drawing) can be found in this presentation by Elliott Sprehn from the Google Feedback team:
http://www.elliottsprehn.com/preso/fluentconf/






share|improve this answer














JavaScript can read the DOM and render a fairly accurate representation of that using canvas. I have been working on a script which converts HTML into a canvas image. Decided today to make an implementation of it into sending feedbacks like you described.



The script allows you to create feedback forms which include a screenshot, created on the client's browser, along with the form. The screenshot is based on the DOM and as such may not be 100% accurate to the real representation as it does not make an actual screenshot, but builds the screenshot based on the information available on the page.



It does not require any rendering from the server, as the whole image is created on the client's browser. The HTML2Canvas script itself is still in a very experimental state, as it does not parse nearly as much of the CSS3 attributes I would want it to, nor does it have any support to load CORS images even if a proxy was available.



Still quite limited browser compatibility (not because more couldn't be supported, just haven't had time to make it more cross browser supported).



For more information, have a look at the examples here:



http://hertzen.com/experiments/jsfeedback/



edit
The html2canvas script is now available separately here and some examples here.



edit 2
Another confirmation that Google uses a very similar method (in fact, based on the documentation, the only major difference is their async method of traversing/drawing) can be found in this presentation by Elliott Sprehn from the Google Feedback team:
http://www.elliottsprehn.com/preso/fluentconf/







share|improve this answer














share|improve this answer



share|improve this answer








edited Sep 20 at 9:16









Pang

6,8301563101




6,8301563101










answered Jul 13 '11 at 11:29









Niklas

25.7k44166




25.7k44166








  • 1




    Very cool, Sikuli or Selenium might be good for going to different sites, comparing a shot of the site from the testing tool to your html2canvas.js rendered image in terms of pixel similarity! Wonder if you could automatically traverse parts of the DOM with a very simple formula solver to find how to parse alternate data sources for browsers where getBoundingClientRect isn't available. I'd probably use this if it was open source, was considering toying with it myself. Nice work Niklas!
    – Luke Stanley
    Jul 15 '11 at 19:25






  • 1




    @Luke Stanley I will most likely throw the source up on github this weekend,still some minor clean ups and changes I want to do before then, as well as get rid of the unnecessary jQuery dependancy it currently has.
    – Niklas
    Jul 15 '11 at 19:43






  • 36




    The source code is now available at github.com/niklasvh/html2canvas, some examples of the script in use html2canvas.hertzen.com there. Still lot of bugs to fix, so I wouldn't recommend using the script in a live environment yet.
    – Niklas
    Jul 16 '11 at 1:42






  • 1




    @trusktr I've replied to the question at github.com/niklasvh/html2canvas/issues/56
    – Niklas
    Feb 20 '12 at 15:32






  • 1




    any solution to make it work for SVG will be a great help. It does not work with highcharts.com
    – Jagdeep
    Dec 25 '12 at 6:26














  • 1




    Very cool, Sikuli or Selenium might be good for going to different sites, comparing a shot of the site from the testing tool to your html2canvas.js rendered image in terms of pixel similarity! Wonder if you could automatically traverse parts of the DOM with a very simple formula solver to find how to parse alternate data sources for browsers where getBoundingClientRect isn't available. I'd probably use this if it was open source, was considering toying with it myself. Nice work Niklas!
    – Luke Stanley
    Jul 15 '11 at 19:25






  • 1




    @Luke Stanley I will most likely throw the source up on github this weekend,still some minor clean ups and changes I want to do before then, as well as get rid of the unnecessary jQuery dependancy it currently has.
    – Niklas
    Jul 15 '11 at 19:43






  • 36




    The source code is now available at github.com/niklasvh/html2canvas, some examples of the script in use html2canvas.hertzen.com there. Still lot of bugs to fix, so I wouldn't recommend using the script in a live environment yet.
    – Niklas
    Jul 16 '11 at 1:42






  • 1




    @trusktr I've replied to the question at github.com/niklasvh/html2canvas/issues/56
    – Niklas
    Feb 20 '12 at 15:32






  • 1




    any solution to make it work for SVG will be a great help. It does not work with highcharts.com
    – Jagdeep
    Dec 25 '12 at 6:26








1




1




Very cool, Sikuli or Selenium might be good for going to different sites, comparing a shot of the site from the testing tool to your html2canvas.js rendered image in terms of pixel similarity! Wonder if you could automatically traverse parts of the DOM with a very simple formula solver to find how to parse alternate data sources for browsers where getBoundingClientRect isn't available. I'd probably use this if it was open source, was considering toying with it myself. Nice work Niklas!
– Luke Stanley
Jul 15 '11 at 19:25




Very cool, Sikuli or Selenium might be good for going to different sites, comparing a shot of the site from the testing tool to your html2canvas.js rendered image in terms of pixel similarity! Wonder if you could automatically traverse parts of the DOM with a very simple formula solver to find how to parse alternate data sources for browsers where getBoundingClientRect isn't available. I'd probably use this if it was open source, was considering toying with it myself. Nice work Niklas!
– Luke Stanley
Jul 15 '11 at 19:25




1




1




@Luke Stanley I will most likely throw the source up on github this weekend,still some minor clean ups and changes I want to do before then, as well as get rid of the unnecessary jQuery dependancy it currently has.
– Niklas
Jul 15 '11 at 19:43




@Luke Stanley I will most likely throw the source up on github this weekend,still some minor clean ups and changes I want to do before then, as well as get rid of the unnecessary jQuery dependancy it currently has.
– Niklas
Jul 15 '11 at 19:43




36




36




The source code is now available at github.com/niklasvh/html2canvas, some examples of the script in use html2canvas.hertzen.com there. Still lot of bugs to fix, so I wouldn't recommend using the script in a live environment yet.
– Niklas
Jul 16 '11 at 1:42




The source code is now available at github.com/niklasvh/html2canvas, some examples of the script in use html2canvas.hertzen.com there. Still lot of bugs to fix, so I wouldn't recommend using the script in a live environment yet.
– Niklas
Jul 16 '11 at 1:42




1




1




@trusktr I've replied to the question at github.com/niklasvh/html2canvas/issues/56
– Niklas
Feb 20 '12 at 15:32




@trusktr I've replied to the question at github.com/niklasvh/html2canvas/issues/56
– Niklas
Feb 20 '12 at 15:32




1




1




any solution to make it work for SVG will be a great help. It does not work with highcharts.com
– Jagdeep
Dec 25 '12 at 6:26




any solution to make it work for SVG will be a great help. It does not work with highcharts.com
– Jagdeep
Dec 25 '12 at 6:26












up vote
57
down vote













Your web app can now take a 'native' screenshot of the client's entire desktop using getUserMedia():



Have a look at this example:



https://www.webrtc-experiment.com/Pluginfree-Screen-Sharing/



The client will have to be using chrome (for now) and will need to enable screen capture support under chrome://flags.






share|improve this answer



















  • 11




    Can you tell me please why you want to screenshot my whole desktop? I used until now Chrome, now I'm thinking to uninstall it, even if I'm satisfied with it's possibilities. I don't like that as a End-user, someone making a screenshot of my desktop!
    – XMight
    Oct 4 '14 at 12:55






  • 2




    i can't find any demos of just taking a screenshot -- everything is all about screen-sharing. will have to try it.
    – jwl
    Oct 16 '14 at 14:56






  • 7




    @XMight, you can choose whether to allow this by toggling the screen capture support flag.
    – Matt Sinclair
    Nov 10 '14 at 15:20






  • 9




    @XMight Please don't think like this. Web browsers should be able to do a lot of things, but unfortunately they are not consistent with their implementations. It is absolutely ok, if a browser has such functionality, as long as the user is being asked. No one will be able to make a screenshot without your attention. But too much fear results in bad implementations, like the clipboard API, which has been disabled altogether, instead creating confirmation dialogs, like for webcams, mics, screenshot capability, etc.
    – StanE
    May 24 '17 at 17:50






  • 3




    This was deprecated and will be removed from the standard according to developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
    – Agustin Cautin
    Feb 16 at 8:10















up vote
57
down vote













Your web app can now take a 'native' screenshot of the client's entire desktop using getUserMedia():



Have a look at this example:



https://www.webrtc-experiment.com/Pluginfree-Screen-Sharing/



The client will have to be using chrome (for now) and will need to enable screen capture support under chrome://flags.






share|improve this answer



















  • 11




    Can you tell me please why you want to screenshot my whole desktop? I used until now Chrome, now I'm thinking to uninstall it, even if I'm satisfied with it's possibilities. I don't like that as a End-user, someone making a screenshot of my desktop!
    – XMight
    Oct 4 '14 at 12:55






  • 2




    i can't find any demos of just taking a screenshot -- everything is all about screen-sharing. will have to try it.
    – jwl
    Oct 16 '14 at 14:56






  • 7




    @XMight, you can choose whether to allow this by toggling the screen capture support flag.
    – Matt Sinclair
    Nov 10 '14 at 15:20






  • 9




    @XMight Please don't think like this. Web browsers should be able to do a lot of things, but unfortunately they are not consistent with their implementations. It is absolutely ok, if a browser has such functionality, as long as the user is being asked. No one will be able to make a screenshot without your attention. But too much fear results in bad implementations, like the clipboard API, which has been disabled altogether, instead creating confirmation dialogs, like for webcams, mics, screenshot capability, etc.
    – StanE
    May 24 '17 at 17:50






  • 3




    This was deprecated and will be removed from the standard according to developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
    – Agustin Cautin
    Feb 16 at 8:10













up vote
57
down vote










up vote
57
down vote









Your web app can now take a 'native' screenshot of the client's entire desktop using getUserMedia():



Have a look at this example:



https://www.webrtc-experiment.com/Pluginfree-Screen-Sharing/



The client will have to be using chrome (for now) and will need to enable screen capture support under chrome://flags.






share|improve this answer














Your web app can now take a 'native' screenshot of the client's entire desktop using getUserMedia():



Have a look at this example:



https://www.webrtc-experiment.com/Pluginfree-Screen-Sharing/



The client will have to be using chrome (for now) and will need to enable screen capture support under chrome://flags.







share|improve this answer














share|improve this answer



share|improve this answer








edited May 17 '16 at 10:09

























answered Oct 29 '13 at 9:33









Matt Sinclair

773510




773510








  • 11




    Can you tell me please why you want to screenshot my whole desktop? I used until now Chrome, now I'm thinking to uninstall it, even if I'm satisfied with it's possibilities. I don't like that as a End-user, someone making a screenshot of my desktop!
    – XMight
    Oct 4 '14 at 12:55






  • 2




    i can't find any demos of just taking a screenshot -- everything is all about screen-sharing. will have to try it.
    – jwl
    Oct 16 '14 at 14:56






  • 7




    @XMight, you can choose whether to allow this by toggling the screen capture support flag.
    – Matt Sinclair
    Nov 10 '14 at 15:20






  • 9




    @XMight Please don't think like this. Web browsers should be able to do a lot of things, but unfortunately they are not consistent with their implementations. It is absolutely ok, if a browser has such functionality, as long as the user is being asked. No one will be able to make a screenshot without your attention. But too much fear results in bad implementations, like the clipboard API, which has been disabled altogether, instead creating confirmation dialogs, like for webcams, mics, screenshot capability, etc.
    – StanE
    May 24 '17 at 17:50






  • 3




    This was deprecated and will be removed from the standard according to developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
    – Agustin Cautin
    Feb 16 at 8:10














  • 11




    Can you tell me please why you want to screenshot my whole desktop? I used until now Chrome, now I'm thinking to uninstall it, even if I'm satisfied with it's possibilities. I don't like that as a End-user, someone making a screenshot of my desktop!
    – XMight
    Oct 4 '14 at 12:55






  • 2




    i can't find any demos of just taking a screenshot -- everything is all about screen-sharing. will have to try it.
    – jwl
    Oct 16 '14 at 14:56






  • 7




    @XMight, you can choose whether to allow this by toggling the screen capture support flag.
    – Matt Sinclair
    Nov 10 '14 at 15:20






  • 9




    @XMight Please don't think like this. Web browsers should be able to do a lot of things, but unfortunately they are not consistent with their implementations. It is absolutely ok, if a browser has such functionality, as long as the user is being asked. No one will be able to make a screenshot without your attention. But too much fear results in bad implementations, like the clipboard API, which has been disabled altogether, instead creating confirmation dialogs, like for webcams, mics, screenshot capability, etc.
    – StanE
    May 24 '17 at 17:50






  • 3




    This was deprecated and will be removed from the standard according to developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
    – Agustin Cautin
    Feb 16 at 8:10








11




11




Can you tell me please why you want to screenshot my whole desktop? I used until now Chrome, now I'm thinking to uninstall it, even if I'm satisfied with it's possibilities. I don't like that as a End-user, someone making a screenshot of my desktop!
– XMight
Oct 4 '14 at 12:55




Can you tell me please why you want to screenshot my whole desktop? I used until now Chrome, now I'm thinking to uninstall it, even if I'm satisfied with it's possibilities. I don't like that as a End-user, someone making a screenshot of my desktop!
– XMight
Oct 4 '14 at 12:55




2




2




i can't find any demos of just taking a screenshot -- everything is all about screen-sharing. will have to try it.
– jwl
Oct 16 '14 at 14:56




i can't find any demos of just taking a screenshot -- everything is all about screen-sharing. will have to try it.
– jwl
Oct 16 '14 at 14:56




7




7




@XMight, you can choose whether to allow this by toggling the screen capture support flag.
– Matt Sinclair
Nov 10 '14 at 15:20




@XMight, you can choose whether to allow this by toggling the screen capture support flag.
– Matt Sinclair
Nov 10 '14 at 15:20




9




9




@XMight Please don't think like this. Web browsers should be able to do a lot of things, but unfortunately they are not consistent with their implementations. It is absolutely ok, if a browser has such functionality, as long as the user is being asked. No one will be able to make a screenshot without your attention. But too much fear results in bad implementations, like the clipboard API, which has been disabled altogether, instead creating confirmation dialogs, like for webcams, mics, screenshot capability, etc.
– StanE
May 24 '17 at 17:50




@XMight Please don't think like this. Web browsers should be able to do a lot of things, but unfortunately they are not consistent with their implementations. It is absolutely ok, if a browser has such functionality, as long as the user is being asked. No one will be able to make a screenshot without your attention. But too much fear results in bad implementations, like the clipboard API, which has been disabled altogether, instead creating confirmation dialogs, like for webcams, mics, screenshot capability, etc.
– StanE
May 24 '17 at 17:50




3




3




This was deprecated and will be removed from the standard according to developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
– Agustin Cautin
Feb 16 at 8:10




This was deprecated and will be removed from the standard according to developer.mozilla.org/en-US/docs/Web/API/Navigator/getUserMedia
– Agustin Cautin
Feb 16 at 8:10










up vote
16
down vote













As Niklas mention you can use html2canvas library to make screenshot using js browser . I will develop his answer in this point by provide example of making screenshot using this library (in this question frame):






function report() {
let region = document.querySelector("body"); // whole screen
html2canvas(region, {
onrendered: function(canvas) {
let pngUrl = canvas.toDataURL(); // png in dataURL format
let img = document.querySelector(".screen");
img.src = pngUrl;

// here you can allow user to set bug-region
// and send it with 'pngUrl' to server
},
});
}

.container {
margin-top: 10px;
border: solid 1px black;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div>Screenshot tester</div>
<button onclick="report()">Take screenshot</button>

<div class="container">
<img width="75%" class="screen">
</div>





In report() function in onrendered after getting image as data-uri you can show it to user and allow him to draw "bug region" by mouse and then send screenshot and region coordinates to server.



In this example async/await version was made: with nice makeScreenshot() function.






share|improve this answer



















  • 7




    If you wanna give minus point, leave also comment with explanation
    – Kamil Kiełczewski
    Jul 9 at 8:11















up vote
16
down vote













As Niklas mention you can use html2canvas library to make screenshot using js browser . I will develop his answer in this point by provide example of making screenshot using this library (in this question frame):






function report() {
let region = document.querySelector("body"); // whole screen
html2canvas(region, {
onrendered: function(canvas) {
let pngUrl = canvas.toDataURL(); // png in dataURL format
let img = document.querySelector(".screen");
img.src = pngUrl;

// here you can allow user to set bug-region
// and send it with 'pngUrl' to server
},
});
}

.container {
margin-top: 10px;
border: solid 1px black;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div>Screenshot tester</div>
<button onclick="report()">Take screenshot</button>

<div class="container">
<img width="75%" class="screen">
</div>





In report() function in onrendered after getting image as data-uri you can show it to user and allow him to draw "bug region" by mouse and then send screenshot and region coordinates to server.



In this example async/await version was made: with nice makeScreenshot() function.






share|improve this answer



















  • 7




    If you wanna give minus point, leave also comment with explanation
    – Kamil Kiełczewski
    Jul 9 at 8:11













up vote
16
down vote










up vote
16
down vote









As Niklas mention you can use html2canvas library to make screenshot using js browser . I will develop his answer in this point by provide example of making screenshot using this library (in this question frame):






function report() {
let region = document.querySelector("body"); // whole screen
html2canvas(region, {
onrendered: function(canvas) {
let pngUrl = canvas.toDataURL(); // png in dataURL format
let img = document.querySelector(".screen");
img.src = pngUrl;

// here you can allow user to set bug-region
// and send it with 'pngUrl' to server
},
});
}

.container {
margin-top: 10px;
border: solid 1px black;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div>Screenshot tester</div>
<button onclick="report()">Take screenshot</button>

<div class="container">
<img width="75%" class="screen">
</div>





In report() function in onrendered after getting image as data-uri you can show it to user and allow him to draw "bug region" by mouse and then send screenshot and region coordinates to server.



In this example async/await version was made: with nice makeScreenshot() function.






share|improve this answer














As Niklas mention you can use html2canvas library to make screenshot using js browser . I will develop his answer in this point by provide example of making screenshot using this library (in this question frame):






function report() {
let region = document.querySelector("body"); // whole screen
html2canvas(region, {
onrendered: function(canvas) {
let pngUrl = canvas.toDataURL(); // png in dataURL format
let img = document.querySelector(".screen");
img.src = pngUrl;

// here you can allow user to set bug-region
// and send it with 'pngUrl' to server
},
});
}

.container {
margin-top: 10px;
border: solid 1px black;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div>Screenshot tester</div>
<button onclick="report()">Take screenshot</button>

<div class="container">
<img width="75%" class="screen">
</div>





In report() function in onrendered after getting image as data-uri you can show it to user and allow him to draw "bug region" by mouse and then send screenshot and region coordinates to server.



In this example async/await version was made: with nice makeScreenshot() function.






function report() {
let region = document.querySelector("body"); // whole screen
html2canvas(region, {
onrendered: function(canvas) {
let pngUrl = canvas.toDataURL(); // png in dataURL format
let img = document.querySelector(".screen");
img.src = pngUrl;

// here you can allow user to set bug-region
// and send it with 'pngUrl' to server
},
});
}

.container {
margin-top: 10px;
border: solid 1px black;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div>Screenshot tester</div>
<button onclick="report()">Take screenshot</button>

<div class="container">
<img width="75%" class="screen">
</div>





function report() {
let region = document.querySelector("body"); // whole screen
html2canvas(region, {
onrendered: function(canvas) {
let pngUrl = canvas.toDataURL(); // png in dataURL format
let img = document.querySelector(".screen");
img.src = pngUrl;

// here you can allow user to set bug-region
// and send it with 'pngUrl' to server
},
});
}

.container {
margin-top: 10px;
border: solid 1px black;
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<div>Screenshot tester</div>
<button onclick="report()">Take screenshot</button>

<div class="container">
<img width="75%" class="screen">
</div>






share|improve this answer














share|improve this answer



share|improve this answer








edited 5 hours ago

























answered Jul 1 at 19:25









Kamil Kiełczewski

8,28375587




8,28375587








  • 7




    If you wanna give minus point, leave also comment with explanation
    – Kamil Kiełczewski
    Jul 9 at 8:11














  • 7




    If you wanna give minus point, leave also comment with explanation
    – Kamil Kiełczewski
    Jul 9 at 8:11








7




7




If you wanna give minus point, leave also comment with explanation
– Kamil Kiełczewski
Jul 9 at 8:11




If you wanna give minus point, leave also comment with explanation
– Kamil Kiełczewski
Jul 9 at 8:11





protected by NullPoiиteя Jun 23 '13 at 10:11



Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



Would you like to answer one of these unanswered questions instead?



Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

How to ignore python UserWarning in pytest?

Alexandru Averescu