diff options
author | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:43:23 -0500 |
---|---|---|
committer | Peter Bengtsson <mail@peterbe.com> | 2020-12-08 14:43:23 -0500 |
commit | 218934fa2ed1c702a6d3923d2aa2cc6b43c48684 (patch) | |
tree | a9ef8ac1e1b8fe4207b6d64d3841bfb8990b6fd0 /files/zh-tw/web/api/url | |
parent | 074785cea106179cb3305637055ab0a009ca74f2 (diff) | |
download | translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.gz translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.tar.bz2 translated-content-218934fa2ed1c702a6d3923d2aa2cc6b43c48684.zip |
initial commit
Diffstat (limited to 'files/zh-tw/web/api/url')
-rw-r--r-- | files/zh-tw/web/api/url/createobjecturl/index.html | 137 | ||||
-rw-r--r-- | files/zh-tw/web/api/url/index.html | 212 |
2 files changed, 349 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> diff --git a/files/zh-tw/web/api/url/index.html b/files/zh-tw/web/api/url/index.html new file mode 100644 index 0000000000..0a7fdb670b --- /dev/null +++ b/files/zh-tw/web/api/url/index.html @@ -0,0 +1,212 @@ +--- +title: URL +slug: Web/API/URL +tags: + - API + - Experimental + - NeedsTranslation + - TopicStub + - URL API +translation_of: Web/API/URL +--- +<div>{{ApiRef("URL API")}} {{SeeCompatTable}}</div> + +<p><strong><code>URL</code></strong> 介面提供了建立 <code>URL</code> 物件的靜態方法。</p> + +<p>使用尚未實作此物件的瀏覽器時,可以改用 {{domxref("Window.URL")}} 屬性來呼叫(基於 Webkit 或 Blink 引擎的瀏覽器可使用 <code>Window.webkitURL</code>)。</p> + +<p>{{AvailableInWorkers}}</p> + +<h2 id="屬性">屬性</h2> + +<dl> + <dt>{{domxref("URL.href")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing the whole URL.</dd> + <dt>{{domxref("URL.protocol")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing the protocol scheme of the URL, including the final <code>':'</code>.</dd> + <dt>{{domxref("URL.host")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing the host, that is the <em>hostname</em>, a <code>':'</code>, and the <em>port</em> of the URL.</dd> + <dt>{{domxref("URL.hostname")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing the domain of the URL.</dd> + <dt>{{domxref("URL.port")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing the port number of the URL.</dd> + <dt>{{domxref("URL.pathname")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing an initial <code>'/'</code> followed by the path of the URL.</dd> + <dt>{{domxref("URL.search")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing a <code>'?'</code> followed by the parameters of the URL.</dd> + <dt>{{domxref("URL.hash")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing a <code>'#'</code> followed by the fragment identifier of the URL.</dd> + <dt>{{domxref("URL.username")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing the username specified before the domain name.</dd> + <dt>{{domxref("URL.password")}}</dt> + <dd>Is a {{domxref("DOMString")}} containing the password specified before the domain name.</dd> + <dt>{{domxref("URL.origin")}} {{readonlyInline}}</dt> + <dd>Returns a {{domxref("DOMString")}} containing the origin of the URL, that is its scheme, its domain and its port.</dd> +</dl> + +<dl> + <dt>{{domxref("URL.searchParams")}}</dt> + <dd>Returns a {{domxref("URLSearchParams")}} object allowing to access the GET query arguments contained in the URL.</dd> +</dl> + +<h2 id="建構式">建構式</h2> + +<dl> + <dt>{{domxref("URL.URL", "URL()")}}</dt> + <dd>Creates and return a <code>URL</code> object composed from the given parameters.</dd> +</dl> + +<h2 id="方法">方法</h2> + +<p><em>The <code>URL</code> interface implements methods defined in {{domxref("URLUtils")}}.</em></p> + +<dl> + <dt>{{domxref("URLUtils.toString()")}}</dt> + <dd>Returns a {{domxref("DOMString")}} containing the whole URL. It is a synonym for {{domxref("URLUtils.href")}}, though it can't be used to modify the value.</dd> +</dl> + +<h2 id="靜態方法">靜態方法</h2> + +<dl> + <dt>{{domxref("URL.createObjectURL()")}}</dt> + <dd>Returns a {{domxref("DOMString")}} containing a unique blob URL, that is a URL with <code>blob:</code> as its scheme, followed by an opaque string uniquely identifying the object in the browser.</dd> + <dt>{{domxref("URL.revokeObjectURL()")}}</dt> + <dd>Revokes an object URL previously created using {{domxref("URL.createObjectURL()")}}.</dd> +</dl> + +<h2 id="規範">規範</h2> + +<table class="standard-table"> + <tbody> + <tr> + <th scope="col">Specification</th> + <th scope="col">Status</th> + <th scope="col">Comment</th> + </tr> + <tr> + <td>{{SpecName('File API', '#creating-revoking', 'URL')}}</td> + <td>{{Spec2('File API')}}</td> + <td>Added the static methods <code>URL.createObjectURL()</code> and <code>URL.revokeObjectURL</code><code>()</code>.</td> + </tr> + <tr> + <td>{{SpecName('URL', '#api', 'Node')}}</td> + <td>{{Spec2('URL')}}</td> + <td>Initial definition (implements <code>URLUtils</code>).</td> + </tr> + </tbody> +</table> + +<h2 id="瀏覽器相容性">瀏覽器相容性</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>8.0<sup>[2]</sup><br> + 32</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoDesktop("2.0")}}<sup>[1][3]</sup><br> + {{CompatGeckoDesktop("19.0")}}</td> + <td>10.0</td> + <td>15.0<sup>[2]</sup><br> + 19</td> + <td>6.0<sup>[2]</sup><br> + 7.0</td> + </tr> + <tr> + <td><code>username</code>, <code>password</code>, and <code>origin</code></td> + <td>32</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoDesktop("26.0")}}</td> + <td>{{CompatUnknown}}</td> + <td>19</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + <tr> + <td><code>searchParams</code></td> + <td>{{CompatChrome(49)}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatGeckoDesktop("29.0")}}</td> + <td>{{CompatUnknown}}</td> + <td>36</td> + <td>{{CompatNo}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Chrome for Android</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>4<sup>[2]</sup><br> + 4.4</td> + <td>8.0<sup>[2]</sup><br> + 32</td> + <td>{{CompatGeckoMobile("14.0")}}<sup>[1][3]</sup><br> + {{CompatGeckoMobile("19.0")}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>15.0<sup>[2]</sup></td> + <td>6.0<sup>[2]</sup></td> + </tr> + <tr> + <td><code>username</code>, <code>password</code>, and <code>origin</code></td> + <td>4.4</td> + <td>32</td> + <td>{{CompatGeckoDesktop("26.0")}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + <tr> + <td><code>searchParams</code></td> + <td>{{CompatNo}}</td> + <td>{{CompatChrome(49)}}</td> + <td>{{CompatGeckoMobile("29.0")}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + <td>{{CompatUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<p>[1] From Gecko 2 (Firefox 4) to Gecko 18 included, Gecko supported this interface with the non-standard <code>nsIDOMMozURLProperty</code> internal type. As the only to access such an object was through {{domxref("window.URL")}}, in practice, this didn't make any difference.</p> + +<p>[2] This feature is implemented under the non-standard name <code>webkitURL</code>.</p> + +<p>[3] For Firefox, to use from chrome code, JSM and Bootstrap scope, you have to import it like this:</p> + +<pre class="brush: js">Cu.importGlobalProperties(['URL']); +</pre> + +<p><code>URL</code> is available in Worker scopes.</p> + +<h2 id="參見">參見</h2> + +<ul> + <li>Property allowing to get such an object: {{domxref("Window.URL")}}.</li> + <li><a href="/en-US/docs/Components.utils.importGlobalProperties">Components.utils.importGlobalProperties</a></li> +</ul> |