window.URL.createObjectURL(BLOB);在我的应用程序是未定义 [英] window.URL.createObjectURL(blob); is undefined in my application

查看:9136
本文介绍了window.URL.createObjectURL(BLOB);在我的应用程序是未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在面临这个问题只在我的应用程序,不论浏览器(IE&安培;铬)。如果我检查 window.URL.createObjectURL(BLOB)在这两个浏览器,其做工精细任何其他网页的控制台。 (

I'm facing this issue only in my application irrespective of browser (IE & Chrome). If I check window.URL.createObjectURL(blob) in console of any other page in both the browsers, its working fine. But it window.URL.createObjectURL(blob) is getting undefined only in the tab in which I open my application :(

我不知道,这库移除createObjectURL的方法。

I'm not sure, which library is removing "createObjectURL" method.

以下是我的剧本

<script src="src/js/libs/jquery/dist/jquery.js"></script>
<script src="src/js/libs/toastr/toastr.js"></script>
<script src="src/js/libs/moment/moment.js"></script>
<script src="src/js/libs/bootstrap/dist/js/bootstrap.js"></script>
<script src="src/js/libs/angular/angular.js"></script>
<script src="src/js/libs/angular-route/angular-route.js"></script>
<script src="src/js/libs/angular-sanitize/angular-sanitize.js></script>
<script src="src/js/libs/angular-animate/angular-animate.js"></script>
<script src="src/js/libs/angular-mocks/angular-mocks.js"></script>
<script src="src/js/libs/angular-bootstrap/ui-bootstrap-tpls.js"></script>

我无法弄清楚如何获得 window.URL.createObjectURL

下面是在IE控制台错误

Here is the error in IE console

错误:[IGL]对象不支持属性或方法createObjectURL
  类型错误:对象不支持属性或方法createObjectURL

Error: [IGL] Object doesn't support property or method 'createObjectURL' TypeError: Object doesn't support property or method 'createObjectURL'

下面是在Chrome中误差

Here is the error in Chrome

错误:[IGL] window.URL.createObjectURL不是函数
  类型错误:window.URL.createObjectURL不是一个函数

Error: [IGL] window.URL.createObjectURL is not a function TypeError: window.URL.createObjectURL is not a function

在此先感谢

推荐答案

我想出这个解决方案通过下面的脚本从阿伦&安培; @Phil意见。多亏了他们两个。

I figure out the solution for this by using following script from Arun & @Phil comments. Thanks to both of them.

它不与任何库,在我未使用code的地方应用,有它覆盖window.URL一个全球性的URL对象。

Its not with any library, in my application somewhere in unused code, there a global URL object which is overriding the window.URL.

我发现这个通过以下code:

I found this by using the following code:

(function () {
        var _createObjectURL = window.URL.createObjectURL;
                Object.defineProperty(window.URL, 'createObjectURL', {
                set: function (value) {
                console.trace('set createObjectURL')
                        _createObjectURL = value;
                },
                        get: function () {
                        console.trace('get createObjectURL')
                                return _createObjectURL;
                        }
                })
                })();
                (function () {
                var _URL = window.URL;
                        Object.defineProperty(window, 'URL', {
                        set: function (value) {
                        console.trace('set URL')
                                _URL = value;
                        },
                                get: function () {
                                console.trace('get URL')
                                        return _URL;
                                }
                        })
                        })();  

这篇关于window.URL.createObjectURL(BLOB);在我的应用程序是未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆