aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/mozilla/add-ons/webextensions/api/search
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/mozilla/add-ons/webextensions/api/search
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/mozilla/add-ons/webextensions/api/search')
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/search/index.html34
-rw-r--r--files/zh-cn/mozilla/add-ons/webextensions/api/search/search/index.html93
2 files changed, 127 insertions, 0 deletions
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/search/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/search/index.html
new file mode 100644
index 0000000000..4a8c5e320b
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/search/index.html
@@ -0,0 +1,34 @@
+---
+title: search
+slug: Mozilla/Add-ons/WebExtensions/API/search
+tags:
+ - API
+ - Add-ons
+ - Extensions
+ - NeedsTranslation
+ - Reference
+ - Search
+ - Search Engines
+ - TopicStub
+ - WebExtensions
+translation_of: Mozilla/Add-ons/WebExtensions/API/search
+---
+<div>{{AddonSidebar}}</div>
+
+<p>Retrieves search engines and executes a search with a specific search engine.</p>
+
+<p>To use this API you need to have the <code>"search"</code> <a href="/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">permission</a>.</p>
+
+<h2 id="Functions">Functions</h2>
+
+<dl>
+ <dt>{{WebExtAPIRef("search.get()")}}</dt>
+ <dd>Retrieve all search engines.</dd>
+ <dt>{{WebExtAPIRef("search.search()")}}</dt>
+ <dd>Search using the specified search engine.</dd>
+ <dt>
+ <h2 id="Browser_compatibility">Browser compatibility</h2>
+ </dt>
+</dl>
+
+<p>{{Compat("webextensions.api.search", 1, 1)}} {{WebExtExamples("h2")}}</p>
diff --git a/files/zh-cn/mozilla/add-ons/webextensions/api/search/search/index.html b/files/zh-cn/mozilla/add-ons/webextensions/api/search/search/index.html
new file mode 100644
index 0000000000..bb3a122a64
--- /dev/null
+++ b/files/zh-cn/mozilla/add-ons/webextensions/api/search/search/index.html
@@ -0,0 +1,93 @@
+---
+title: search.search()
+slug: Mozilla/Add-ons/WebExtensions/API/search/search
+translation_of: Mozilla/Add-ons/WebExtensions/API/search/search
+---
+<div>{{AddonSidebar()}}</div>
+
+<p>使用指定的搜索引擎或默认搜索引擎进行搜索。</p>
+
+<p>结果将显示在一个新的选项卡中,或者如果给出了tabId参数,则显示在由此标识的选项卡中。</p>
+
+<p>要在扩展程序中使用此功能,您必须要求<code>"search"</code> <a href="https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/permissions">有明确许可</a>.</p>
+
+<p>获取安装的搜索引擎, 请使用 {{WebExtAPIRef("search.get()")}}.</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox brush:js notranslate">browser.search.search(
+ searchProperties // object
+)
+</pre>
+
+<h3 id="参数">参数</h3>
+
+<dl class="reference-values">
+ <dt><code>searchProperties</code></dt>
+ <dd>
+ <p><code>object</code>. 拥有以下属性的对象:</p>
+
+ <dl class="reference-values">
+ <dt><code>query</code></dt>
+ <dd><code>字符串</code>. 进行查询的内容。</dd>
+ <dt><code>engine</code>{{optional_inline}}</dt>
+ <dd>
+ <p><code>字符串。</code>.搜索引擎的名称。 如果指定的搜索引擎名称不存在,该函数将引发错误。 如果省略此属性,则使用默认的搜索引擎。</p>
+ </dd>
+ <dt><code>tabId</code>{{optional_inline}}</dt>
+ <dd>
+ <p><font face="consolas, Liberation Mono, courier, monospace"><span style="background-color: rgba(220, 220, 220, 0.5);">整型。</span></font>用于显示搜索结果的选项卡。如果省略此属性,搜索结果将显示在新选项卡中。</p>
+ </dd>
+ </dl>
+ </dd>
+</dl>
+
+<h3 id="返回值">返回值</h3>
+
+<p>无.</p>
+
+<h2 id="浏览器兼容">浏览器兼容</h2>
+
+<p class="hidden">此页面中的兼容性表是根据结构化数据生成的。 如果您想贡献数据,请查看<a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> ,并向我们发送请求请求。</p>
+
+<p>{{Compat("webextensions.api.search.search", 10)}}</p>
+
+<h2 id="例子">例子</h2>
+
+<p>使用默认搜索引擎进行搜索。 结果显示在新选项卡中:</p>
+
+<pre class="brush: js no-line-numbers notranslate">function search() {
+ browser.search.search({
+ query: "styracosaurus"
+ });
+}
+
+browser.browserAction.onClicked.addListener(search);
+</pre>
+
+<p>使用维基百科进行搜索。 结果显示在新选项卡中:</p>
+
+<pre class="brush: js no-line-numbers notranslate">function search() {
+ browser.search.search({
+ query: "styracosaurus",
+ engine: "Wikipedia (en)"
+ });
+}
+
+browser.browserAction.onClicked.addListener(search);
+</pre>
+
+<p>使用维基百科进行搜索。 结果将显示在活动选项卡中:</p>
+
+<pre class="brush: js no-line-numbers notranslate">function search(tab) {
+ browser.search.search({
+ query: "styracosaurus",
+ engine: "Wikipedia (en)",
+ tabId: tab.id
+ });
+}
+
+browser.browserAction.onClicked.addListener(search);
+</pre>
+
+<p>{{WebExtExamples}}</p>