aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/web/api/url/createobjecturl
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:43:23 -0500
commit218934fa2ed1c702a6d3923d2aa2cc6b43c48684 (patch)
treea9ef8ac1e1b8fe4207b6d64d3841bfb8990b6fd0 /files/zh-tw/web/api/url/createobjecturl
parent074785cea106179cb3305637055ab0a009ca74f2 (diff)
downloadtranslated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.gz
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.bz2
translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.zip
initial commit
Diffstat (limited to 'files/zh-tw/web/api/url/createobjecturl')
-rw-r--r--files/zh-tw/web/api/url/createobjecturl/index.html137
1 files changed, 137 insertions, 0 deletions
diff --git a/files/zh-tw/web/api/url/createobjecturl/index.html b/files/zh-tw/web/api/url/createobjecturl/index.html
new file mode 100644
index 0000000000..8760dffaec
--- /dev/null
+++ b/files/zh-tw/web/api/url/createobjecturl/index.html
@@ -0,0 +1,137 @@
+---
+title: URL.createObjectURL()
+slug: Web/API/URL/createObjectURL
+translation_of: Web/API/URL/createObjectURL
+---
+<div>{{ApiRef("URL API")}}{{SeeCompatTable}}</div>
+
+<h2 id="摘要">摘要</h2>
+
+<p>靜態方法 <strong><code>URL.createObjectURL()</code></strong> 用於建立一個帶有URL的 {{domxref("DOMString")}} 以代表參數中所傳入的物件. 該URL的生命週期與創造它的window中的 {{domxref("document")}}一致. 這個新的物件URL 代表了所指定的 {{domxref("File")}} 物件 或是 {{domxref("Blob")}} 物件.</p>
+
+<p>{{AvailableInWorkers}}</p>
+
+<h2 id="語法">語法</h2>
+
+<pre class="syntaxbox"><em>objectURL</em> = URL.createObjectURL(<em>blob</em>);
+</pre>
+
+<h2 id="參數">參數</h2>
+
+<dl>
+ <dt><em>blob</em></dt>
+</dl>
+
+<dl>
+ <dd>一個用以建立物件URL的 {{domxref("File")}} 物件 或是 {{domxref("Blob")}} 物件.</dd>
+</dl>
+
+<ul>
+</ul>
+
+<h2 id="範例">範例</h2>
+
+<p>參見 <a href="/en-US/docs/Using_files_from_web_applications#Example.3A_Using_object_URLs_to_display_images" title="https://developer.mozilla.org/en/Using_files_from_web_applications#Example:_Using_object_URLs_to_display_images">Using object URLs to display images</a>.(藉由物件URL來顯示圖像)</p>
+
+<h2 id="注意事項">注意事項</h2>
+
+<p>每次呼叫 <code>createObjectURL()</code> 都會產生一個新的URL, 不論是否曾以同一物件產生過. 當你不再需要它們的時候必須對每一個都呼叫 {{domxref("URL.revokeObjectURL()")}} 來釋放它們. 瀏覽器會在document被unload時自動釋放它們; 然而, 為了最佳化效能與記憶體用量, 當有安全的時機請務必手動釋放它們.</p>
+
+<h2 id="規範文件">規範文件</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">規範文件</th>
+ <th scope="col">狀態</th>
+ <th scope="col">附註</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('File API', '#dfn-createObjectURL', 'URL')}}</td>
+ <td>{{Spec2('File API')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="瀏覽器相容性">瀏覽器相容性</h2>
+
+<p>{{CompatibilityTable}}</p>
+
+<div id="compat-desktop">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>功能</th>
+ <th>Chrome</th>
+ <th>Firefox (Gecko)</th>
+ <th>Internet Explorer</th>
+ <th>Opera</th>
+ <th>Safari (WebKit)</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>8 [1]<br>
+ {{CompatChrome(23)}}</td>
+ <td>{{CompatGeckoDesktop(2)}}</td>
+ <td>{{CompatIE(10)}}</td>
+ <td>{{CompatOpera(15)}}</td>
+ <td>{{CompatSafari(6)}} [1]<br>
+ {{CompatSafari(7)}}</td>
+ </tr>
+ <tr>
+ <td>In a {{ domxref("Worker", "Web Worker") }}</td>
+ <td>10 [1]<br>
+ {{CompatChrome(23)}}</td>
+ <td>{{CompatGeckoDesktop(21)}}</td>
+ <td>{{CompatIE(11)}}</td>
+ <td>{{CompatOpera(15)}}</td>
+ <td>{{CompatSafari(6)}} [1]<br>
+ {{CompatSafari(7)}}</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<div id="compat-mobile">
+<table class="compat-table">
+ <tbody>
+ <tr>
+ <th>Feature</th>
+ <th>Chrome for Android</th>
+ <th>Android</th>
+ <th>Firefox Mobile (Gecko)</th>
+ <th>IE Phone</th>
+ <th>Opera Mobile</th>
+ <th>Safari Mobile</th>
+ </tr>
+ <tr>
+ <td>Basic support</td>
+ <td>18 [1]</td>
+ <td>4.0 [1]</td>
+ <td>{{CompatGeckoMobile(14)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOpera(15)}} [1]</td>
+ <td>6.0 [1]</td>
+ </tr>
+ <tr>
+ <td>In a {{ domxref("Worker", "Web Worker") }}</td>
+ <td>18 [1]</td>
+ <td>{{CompatVersionUnknown}} [1]</td>
+ <td>{{CompatGeckoMobile(14)}}</td>
+ <td>{{CompatUnknown}}</td>
+ <td>{{CompatOpera(15)}} [1]</td>
+ <td>6.0 [1]</td>
+ </tr>
+ </tbody>
+</table>
+</div>
+
+<p>[1]  在該瀏覽器中必須使用 <code>webkitURL 而非 <a href="/en-US/docs/Web/API/URL">URL</a></code></p>
+
+<h2 id="另見">另見</h2>
+
+<ul>
+ <li>{{domxref("URL.revokeObjectURL()")}}</li>
+ <li><a href="/en-US/docs/Using_files_from_web_applications" title="Using files from web applications">Using files from web applications</a></li>
+</ul>