How to choose between `window.URL.createObjectURL()` and `window.webkitURL.createObjectURL()` based on browser

后端 未结 3 1453
失恋的感觉
失恋的感觉 2020-12-30 05:13

From the Firefox developer website, I know that Firefox uses

objectURL = window.URL.createObjectURL(file);

to get url of file type, but in

3条回答
  •  被撕碎了的回忆
    2020-12-30 05:56

    if (window.URL !== undefined) {
        window.URL.createObjectURL();
    } else if (window.webkitURL !== undefined) {
        window.webkitURL.createObjectURL();
    } else {
        console.log('Method Unavailable: createObjectURL');
    }
    

    Is round-about what you're looking for. Also, THIS example uses the much simpler...

    window.URL = window.URL || window.webkitURL;
    

提交回复
热议问题