根據瀏覽器選擇 `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 );

更新時間: 2020-06-25

573 瀏覽量

開啟您的 職業生涯

透過完成課程獲得認證

馬上開始
廣告
© . All rights reserved.