createObjectURL is returning undefined in Chrome(createObjectURL 在 Chrome 中返回未定义)
问题描述
尝试使用 createObjectDataURL 更改视频源文件.它在 Firefox 中运行良好,但在 Chrome(版本 12.0.742.122 m)中无法运行.代码不会引发任何错误,但会为 createObjectDataURL 返回未定义.我尝试了所有的可能性,但它总是返回未定义.
<!DOCTYPE html><html><头><title>检查 CreateObjectURL</title></头><脚本类型=文本/javascript"语言=javascript">窗口.URL = 窗口.URL ||窗口.webkitURL;函数更改属性(){var v = document.getElementById("myvideo");var file = document.getElementById("fileControl").files[0];v.setAttribute("src",window.URL.createObjectURL(file));}</脚本><身体><video id="myvideo" src="bW92aWUub2dn" 控件></video><输入类型="文件" id="文件控制"/><button id="btnprops" onClick="ChangeProperty()" >更新</button></div></身体></html>请帮助我.它已经花费了很多时间.提前致谢.
解决方案 我在 Chrome 中将页面作为本地文件打开时遇到了同样的问题.我必须使用 Apache 并通过 localhost 打开它.
Trying to change video source file using createObjectDataURL. It is working fine with Firefox but not working in Chrome (version 12.0.742.122 m). code is not throwing any error but returns undefined for createObjectDataURL. I tried all the possibilities but it always returns undefined.
<!DOCTYPE html>
<html>
<head>
<title>Check CreateObjectURL</title>
</head>
<script type="text/javascript" language="javascript">
window.URL = window.URL || window.webkitURL;
function ChangeProperty()
{
var v = document.getElementById("myvideo");
var file = document.getElementById("fileControl").files[0];
v.setAttribute("src",window.URL.createObjectURL(file));
}
</script>
<body>
<div >
<video id="myvideo" src="bW92aWUub2dn" controls ></video>
<input type="file" id="fileControl" />
<button id="btnprops" onClick="ChangeProperty()" >update</button>
</div>
</body>
</html>
Please help me. It has already taken lot of time.
Thanks in Advance.
解决方案 I had the same problem, when I was opening the page as a local file in Chrome. I had to use Apache and open it through localhost.
这篇关于createObjectURL 在 Chrome 中返回未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:createObjectURL 在 Chrome 中返回未定义


- 400或500级别的HTTP响应 2022-01-01
- Fetch API 如何获取响应体? 2022-01-01
- Css:将嵌套元素定位在父元素边界之外一点 2022-09-07
- Quasar 2+Apollo:错误:找不到ID为默认的Apollo客户端。如果您在组件设置之外,请使用ProvideApolloClient() 2022-01-01
- 使用RSelum从网站(报纸档案)中抓取多个网页 2022-09-06
- addEventListener 在 IE 11 中不起作用 2022-01-01
- 失败的 Canvas 360 jquery 插件 2022-01-01
- Flexslider 箭头未正确显示 2022-01-01
- CSS媒体查询(最大高度)不起作用,但为什么? 2022-01-01
- 如何使用 JSON 格式的 jQuery AJAX 从 .cfm 页面输出查 2022-01-01