为什么在浏览器之间显示我的网络摄像头图像会有所不同
Why the difference in displaying my webcam image across browsers?
我有一个IP网络摄像头,并将图像上传到气象服务。然后,我捕获该图像以显示在我的网页中。为了做到这一点,我搜索了一些可以在不刷新页面的情况下刷新图像的代码。我找到了一些我改编的代码(对不起,我不知道该承认谁)......
<script>
var reimg
window.onload=function () {
reimg=document.getElementById('re')
setInterval(function () {
reimg.src=reimg.src.replace(/'?.*/,function () {
return '?'+new Date()
})
},60000)
}
</script>
下一点,在很大程度上,可能是矫枉过正,但我一直在努力让它在所有浏览器上工作(我希望它的外观)......
<iframe frameborder=0 marginwidth=0 marginheight=0 border=0 width="360" height="270" style="overflow:
hidden;border:0;margin:0;width:360px;height:270px;max-width:100%;max-height:100%"
src="http://icons.wunderground.com/webcamramdisk/g/l/Gluepack/1/current.jpg?" id="re" scrolling="no"
allowtransparency="true">If you can see this, your browser doesn't understand IFRAME. However, we'll
still <A HREF="http://icons.wunderground.com/webcamramdisk/g/l/Gluepack/1/current.jpg">link</A>
you to the file.</iframe>
它在 Firefox 中工作正常,减少 640 x 480 的原始图像以适应。但是,在IE和Chrome中,仅显示图像的中心顶部(即图像不会缩小以适合)。是否需要任何其他代码来确保它在IE和Chrome中正确显示(即我想要的方式,缩小以适应),还是不可能?
图像的显示方式实际上取决于浏览器,没有标准。最简单的解决方案是创建一个包含 javascript 和图像<img>
标签的 HTML 文件,而不是将图像直接加载到 iframe 中:
<!DOCTYPE HTML>
<html><head>
<script>
window.onload = function() {
var reimg = document.getElementsByTagName('img')[0];
setInterval(function () {
reimg.src = reimg.src.replace(/'?.*/, function () {
return '?'+new Date()
});
}, 60000);
};
</script>
<style type="text/css">
* { margin: 0; padding: 0; }
img { width: 360px; height: 270px; }
</head><body>
<img src="http://icons.wunderground.com/webcamramdisk/g/l/Gluepack/1/current.jpg?">
</body></html>
将其另存为"网络摄像头.html"或其他任何内容:
<iframe frameborder=0 marginwidth=0 marginheight=0 border=0
width="360" height="270" style="overflow: hidden; border:0;
margin:0; width:360px; height:270px; max-width:100%; max-height:100%"
src="webcam.html" id="re" scrolling="no"
allowtransparency="true">...</iframe>
相关文章:
- 如何使用url加载程序在webpack中导入多个图像
- nodejs-expressjs上传图像并显示它们
- 使用JSP从服务器检索和显示图像
- LocalStorage phonegap摄像头图像
- 使用JavaScript从网络摄像头捕获图像,而无需页面刷新
- 为什么在浏览器之间显示我的网络摄像头图像会有所不同
- 是否有任何jquery插件可以像Facebook墙系统中那样从网络摄像头中捕获图像和视频
- 如何通过用户捕获图像's使用getUserMedia的网络摄像头
- 使用网络摄像头捕捉图像
- 尝试使用javascript camgaze.js绘制图像,从网络摄像头实时检测人脸-不工作
- ASP.Net jQuery网络摄像头图像数据库varbinary(最大)
- 将网络摄像头转换为拉伸/缩放背景图像
- 显示网络摄像头上传的图像和日期时间
- 上传图像从网络摄像头到服务器
- 如何使用Java在网页中立即将网络摄像头数据处理为图像
- 在Asp中使用摄像头进行图像采集.净MVC
- 网络摄像头图像刷新与ajax
- JavaScript, PHP数组帮助摄像头图像,
- 用于网站实现的网络摄像头图像流
- 使用PHP和JavaScript从网络摄像头捕获图像并保存在文件夹中