如何根據瀏覽器在 `window.URL.createObjectURL()` 和 `window.webkitURL.createObjectURL()` 之間進行選擇?


要進行選擇,您需要定義包裝函式 −

function display ( file ) {
   if ( window.webkitURL ) {
      return window.webkitURL.createObjectURL( file );
   } else if ( window.URL && window.URL.createObjectURL ) {
      return window.URL.display( file );
   } else {
   return null;
   }
}

之後,根據瀏覽器進行設定 −

var url = display( file );

更新於: 25-6-2020

572 次瀏覽

開啟你的 職業生涯

透過完成課程獲取認證

開始
廣告
© . All rights reserved.