Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <img src="http://[some ip]:[port]/mjpg">
- <!DOCTYPE html>
- <html>
- <head>
- <title>ipCam</title>
- </head>
- <body>
- <h1>ipCam</h1>
- <img id="motionjpeg" src="http://user:pass@127.0.0.1:8080/" />
- <script src="motionjpeg.js"></script>
- <script>
- //Using jQuery for simplicity
- $(document).ready(function() {
- motionjpeg("#motionjpeg"); // Use the function on the image
- });
- </script>
- </body>
- </html>
- function motionjpeg(id) {
- var image = $(id), src;
- if (!image.length) return;
- src = image.attr("src");
- if (src.indexOf("?") < 0) {
- image.attr("src", src + "?"); // must have querystring
- }
- image.on("load", function() {
- // this cause the load event to be called "recursively"
- this.src = this.src.replace(/?[^n]*$/, "?") +
- (new Date()).getTime(); // 'this' refers to the image
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement