The basic technique, dubbed Clickjacking, is nothing new.
Accessing your webcam via your browser used to involve a...pardon the profanity, a plugin. In order to connect to a webcam and gain access to its video stream, you had to rely on something primarily created in Flash or Silverlight.
While that approach certainly worked for browsers that supported plug-ins, it didn't help for the increasing number of browsers that aim to be plugin-free.
If you are on a recent version of Google Chrome, a security change was made recently where a webcam can only be accessed if the content is served via HTTPS.
You can still develop and test locally (or via localhost), but you won't be able to test it "in the wild" unless you are on a secure HTTPS connection.
In cases when there is an error in getting the video stream or the user refused to give your code permission to access the webcam, the error callback will get called.
In our case, that is handled by the As you can see, I didn't flesh out what the behavior would be. So, there you have it - a look at how you can access a user's webcam video stream and display it in the browser.The good news is, despite its newness, various browsers have already implemented support for accessing the webcam in their latest versions.Because accessing the webcam natively is a recent introduction, check out caniuse's statistics to see the level of support it has among the major browsers.) In writing this tutorial, I used the latest version of Google's Chrome where everything works swimmingly.Let's start at the very top: function is currently vendor prefixed.This means that each browser will expect a different variant of the function to actually work.You know those people who put tape over their laptop’s webcam to keep digital peeping toms at bay? A new proof of concept is making the rounds today that demonstrates how a hacker can snap pics off your webcam, right through the browser, with no consent required. Without going into to much detail, the demo uses a bunch of fancy CSS/HTML trickery to render Flash’s permission prompt in a transparent layer, placing the now invisible “Allow” button directly above something the user is likely to click — like, say, the “Play” button on a video.