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


from firefox developer website, know firefox uses

objecturl = window.url.createobjecturl(file); 

to url of file type, in chrome , other webkit browsers have window.webkiturl.createobjecturl() detecting url.

i don't know how swap functions based on browser engines, , need worked on both browsers (chrome , firefox)

https://developer.mozilla.org/en/dom/window.url.createobjecturl

you define wrapper function:

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;     } } 

and then:

// works cross-browser var url = createobjecturl( file ); 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c++ - Using OpenSSL in a multi-threaded application -

All overlapping substrings matching a java regex -