- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
从 Firefox 开发者网站,我知道 Firefox 使用
objectURL = window.URL.createObjectURL(file);
获取文件类型的 url,但在 chrome 和其他 webkit 浏览器中,我们有 window.webkitURL.createObjectURL()
用于检测 url。
我不知道如何基于浏览器引擎交换这个功能,我需要它在两种浏览器(Chrome 和 firefox)上都能工作
https://developer.mozilla.org/en/DOM/window.URL.createObjectURL
最佳答案
你可以定义一个包装函数:
function createObjectURL ( file ) {
if ( window.webkitURL ) {
return window.webkitURL.createObjectURL( file );
} else if ( window.URL && window.URL.createObjectURL ) {
return window.URL.createObjectURL( file );
} else {
return null;
}
}
然后:
// works cross-browser
var url = createObjectURL( file );
关于javascript - 如何根据浏览器选择 `window.URL.createObjectURL()`和 `window.webkitURL.createObjectURL()`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11277677/
我的一位客户说他们的网站无法在他们的“某些”计算机上打开。它对其他人开放,但对某些人则不然。 http://www.rwhampton.com 他们检查了 Chrome Javascript 控制台,
浏览 createObjectURL ( https://developer.mozilla.org/en-US/docs/Web/API/URL/createObjectURL ) 的 MDN We
在我的 Javascript 代码中,我试图检查由上传的图像创建的 blob URL:alert(window.webkitURL.createObjectURL(files[0])); 在 Safa
我正在尝试在 Safari 中打开一个 Blob,但是当我单击该链接时,它会将我带到一个页面,提示它无法打开以“blob:”开头的 url。以下代码适用于 FireFox,但我希望它也适用于 Safa
在使用 typescript 编译的项目上使用 Angular 2。 尝试创建 blob 图像时出现此错误: 错误 TS2339:类型“Window”上不存在属性“webkitURL” ts代码是:
从 Firefox 开发者网站,我知道 Firefox 使用 objectURL = window.URL.createObjectURL(file); 获取文件类型的 url,但在 chrome 和
window.URL 和 window.webkitURL 不适用于 Safari 5 之前的浏览器版本 function onFileSelected(event) {
我是一名优秀的程序员,十分优秀!