Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. <img src="http://[some ip]:[port]/mjpg">
  2.  
  3. <!DOCTYPE html>
  4. <html>
  5.  
  6. <head>
  7. <title>ipCam</title>
  8. </head>
  9.  
  10. <body>
  11. <h1>ipCam</h1>
  12. <img id="motionjpeg" src="http://user:pass@127.0.0.1:8080/" />
  13. <script src="motionjpeg.js"></script>
  14. <script>
  15. //Using jQuery for simplicity
  16.  
  17. $(document).ready(function() {
  18. motionjpeg("#motionjpeg"); // Use the function on the image
  19. });
  20. </script>
  21. </body>
  22.  
  23. </html>
  24.  
  25. function motionjpeg(id) {
  26. var image = $(id), src;
  27.  
  28. if (!image.length) return;
  29.  
  30. src = image.attr("src");
  31. if (src.indexOf("?") < 0) {
  32. image.attr("src", src + "?"); // must have querystring
  33. }
  34.  
  35. image.on("load", function() {
  36. // this cause the load event to be called "recursively"
  37. this.src = this.src.replace(/?[^n]*$/, "?") +
  38. (new Date()).getTime(); // 'this' refers to the image
  39. });
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement