aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/archive/web
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/archive/web')
-rw-r--r--files/zh-cn/archive/web/e4x/index.html49
-rw-r--r--files/zh-cn/archive/web/e4x_tutorial/accessing_xml_children/index.html111
-rw-r--r--files/zh-cn/archive/web/e4x_tutorial/descendants_and_filters/index.html27
-rw-r--r--files/zh-cn/archive/web/e4x_tutorial/index.html39
-rw-r--r--files/zh-cn/archive/web/e4x_tutorial/introduction/index.html64
-rw-r--r--files/zh-cn/archive/web/e4x_tutorial/namespaces/index.html33
-rw-r--r--files/zh-cn/archive/web/e4x_tutorial/the_global_xml_object/index.html55
-rw-r--r--files/zh-cn/archive/web/index.html12
-rw-r--r--files/zh-cn/archive/web/indexeddb_api_using_javascript_generators_in_firefox/index.html60
-rw-r--r--files/zh-cn/archive/web/javascript/handler.enumerate/index.html114
-rw-r--r--files/zh-cn/archive/web/javascript/index.html12
-rw-r--r--files/zh-cn/archive/web/javascript/legacy_generator_function/index.html54
-rw-r--r--files/zh-cn/archive/web/javascript/legacy_generator_function_statement/index.html65
-rw-r--r--files/zh-cn/archive/web/javascript/microsoft_extensions/activexobject/index.html92
-rw-r--r--files/zh-cn/archive/web/javascript/microsoft_extensions/date.getvardate/index.html40
-rw-r--r--files/zh-cn/archive/web/javascript/microsoft_extensions/index.html70
-rw-r--r--files/zh-cn/archive/web/javascript/reflect.enumerate/index.html120
-rw-r--r--files/zh-cn/archive/web/liveconnect/index.html800
18 files changed, 0 insertions, 1817 deletions
diff --git a/files/zh-cn/archive/web/e4x/index.html b/files/zh-cn/archive/web/e4x/index.html
deleted file mode 100644
index af364a3208..0000000000
--- a/files/zh-cn/archive/web/e4x/index.html
+++ /dev/null
@@ -1,49 +0,0 @@
----
-title: E4X
-slug: Archive/Web/E4X
-translation_of: Archive/Web/E4X
----
-<div>
- <div class="overheadIndicator obsolete obsoleteHeader"><p><strong><span title="This is an obsolete API and is no longer guaranteed to work."><i class="icon-trash"> </i></span> 已废弃</strong><br>This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.</p></div></div>
-<div>
-  </div>
-<div>
- <div class="warning warningHeader">
- <p><strong>Warning:</strong> E4X已经过时.从Firefox 17开始,E4X在普通网页中被默认禁用,从Firefox 20开始,E4X在浏览器界面中被默认禁用,从Firefox 21开始,E4X被完全删除.使用DOMParser/DOMSerializer或者其他算法来代替.</p>
-</div></div>
-<p><strong>ECMAScript for XML</strong> (<strong>E4X</strong>) is a programming language extension that adds native XML support to <a href="/zh-CN/JavaScript" title="zh-CN/JavaScript">JavaScript</a>. It does this by providing access to the XML document in a form that feels natural for ECMAScript programmers. The goal is to provide an alternative, simpler syntax for accessing XML documents than via <a href="/zh-CN/DOM" title="zh-CN/DOM">DOM</a> interfaces. A valid alternative to E4X is a non-native <a href="/zh-CN/JXON" title="zh-CN/JXON">JXON algorithm</a>.</p>
-<p>E4X is standardized by Ecma International in <a class="external" href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMA-357 standard</a> (currently in its second edition, December 2005).</p>
-<p>E4X is implemented (at least partially) in <a href="/zh-CN/SpiderMonkey" title="zh-CN/SpiderMonkey">SpiderMonkey</a> (<a href="/zh-CN/Gecko" title="zh-CN/Gecko">Gecko</a>'s JavaScript engine) and in <a href="/zh-CN/Rhino" title="zh-CN/Rhino">Rhino</a> (JavaScript engine written in Java).</p>
-<p> </p>
-<div class="note">
- <strong>Note:</strong> In Gecko 1.8 based browsers such as Firefox 1.5, E4X is already partially enabled for web page authors. To fully enable E4X, the <code>&lt;script&gt;</code> element needs to have the MIME type "text/javascript;e4x=1" (i.e. have an attribute of the form <code>type="text/javascript;e4x=1"</code>). The difference between the two modes is that without the "e4x=1" MIME type, any statement-level XML/HTML comment literals (<code><span class="nowiki">&lt;!--...--&gt;</span></code>) are ignored for backwards compatibility with the comment hiding trick, and CDATA sections (<code>&lt;![CDATA[...]]&gt;</code>) are not parsed as CDATA literals (which leads to a JS syntax error in HTML since HTML's <code>&lt;script&gt;</code> element produces an implicit CDATA section, and therefore cannot contain explicit CDATA sections).
- <p><span class="comment">someone verify the above</span></p>
-</div>
-<h3 id="Known_bugs_and_limitations" name="Known_bugs_and_limitations">已经的bug和限制</h3>
-<ul>
- <li>It is not currently possible to access a DOM object through E4X (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=270553" title="E4x&lt;->DOM">bug 270553</a>)</li>
- <li>E4X doesn't support parsing XML declaration (</li>
- <li>&lt;?xml version=...?&gt;) (see <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=336551" title='E4X: Implement ability to process new XML("&amp;amp;lt;?xml...?> ...")'>bug 336551</a>). You may get SyntaxError "xml is a reserved identifier" (despite the XML being in a string).</li>
-</ul>
-<p>Workaround:</p>
-<pre class="brush: js">var response = xmlhttprequest.responseText; // bug 270553
-response = response.replace(/^&lt;\?xml\s+version\s*=\s*(["'])[^\1]+\1[^?]*\?&gt;/, ""); // bug 336551
-var e4x = new XML(response);
-</pre>
-<h3 id="Resources" name="Resources">资源</h3>
-<ul>
- <li><a href="/zh-CN/E4X_Tutorial" title="zh-CN/E4X_Tutorial">E4X Tutorial</a> <a class="internal" href="/zh-CN/E4X/Processing_XML_with_E4X" title="zh-CN/E4X/Processing XML with E4X">Processing XML with E4X</a> on MDN.</li>
- <li><a href="/zh-CN/E4X_for_templating" title="zh-CN/E4X for templating">E4X for templating</a></li>
- <li>See the list of<a href="/Special:Tags?tag=E4X&amp;language=en" title="Special:Tags?tag=E4X&amp;language=en"> E4X-related pages</a> on MDN:</li>
- <li><a class="external" href="http://www.ecma-international.org/publications/standards/Ecma-357.htm">ECMA-357 standard</a></li>
- <li><a class="external" href="/presentations/xtech2005/e4x" title="presentations/xtech2005/e4x">Brendan's presentation</a></li>
- <li><a class="external" href="http://web.archive.org/web/20080703182907/http://www.faqts.com/knowledge_base/index.phtml/fid/1762" title="http://web.archive.org/web/20080703182907/http://www.faqts.com/knowledge_base/index.phtml/fid/1762">E4X at faqts.com</a></li>
- <li><a class="external" href="http://rephrase.net/days/07/06/e4x">E4X quick reference at rephrase.net</a></li>
-</ul>
-<h2 id="相关链接">相关链接</h2>
-<ul>
- <li><a class="internal" href="/zh-CN/JXON" title="zh-CN/JXON">JXON</a></li>
- <li><a class="internal" href="/zh-CN/XPath" title="zh-CN/XPath">XPath</a></li>
- <li><a class="internal" href="/zh-CN/XML" title="zh-CN/XML">XML</a></li>
- <li><a class="internal" href="/zh-CN/Parsing_and_serializing_XML" title="zh-CN/Parsing_and_serializing_XML">XML的解析和序列化</a></li>
-</ul>
diff --git a/files/zh-cn/archive/web/e4x_tutorial/accessing_xml_children/index.html b/files/zh-cn/archive/web/e4x_tutorial/accessing_xml_children/index.html
deleted file mode 100644
index 16b4cf8139..0000000000
--- a/files/zh-cn/archive/web/e4x_tutorial/accessing_xml_children/index.html
+++ /dev/null
@@ -1,111 +0,0 @@
----
-title: Accessing XML children
-slug: Archive/Web/E4X_tutorial/Accessing_XML_children
-translation_of: Archive/Web/E4X_tutorial/Accessing_XML_children
----
-<h2 id="访问_XML_子节点">访问 XML 子节点</h2>
-<p>JavaScript 对象通常使用 . 或 [] 来设置性质。</p>
-<pre class="brush: js">var a = {};
-a.foo = 1;
-a["bar"] = 2;</pre>
-<p>在 E4X 中,点(.)和中括号([])操作符用来访问 E4X 元素的子节点。</p>
-<pre class="brush: js">var element1 = &lt;foo&gt;
- &lt;bar/&gt;
- &lt;/foo&gt;;
-var element2 = &lt;baz/&gt;;
-element1.bar.appendChild(element2);
-element1["bar"].appendChild(&lt;quux/&gt;);</pre>
-<p>往 element1 中的 bar 节点添加子节点,生成如下 XML 文档:</p>
-<p><code>&lt;foo&gt;<br>
-   &lt;bar&gt;<br>
-     &lt;baz/&gt;<br>
-     &lt;quux/&gt;<br>
-   &lt;/bar&gt;<br>
- &lt;/foo&gt;</code></p>
-<p>但是要注意,给一个不存在的子元素赋值会创建这个元素。</p>
-<pre class="brush: js">var element1 = &lt;foo/&gt;
-element1.bar = 1;</pre>
-<p>生成</p>
-<p><code>&lt;foo&gt;<br>
-   &lt;bar&gt;1&lt;/bar&gt;<br>
- &lt;/foo&gt;</code></p>
-<p>如果子节点已经存在,点(.)操作符允许你更改它的值。</p>
-<pre class="brush: js">var elem = &lt;foo&gt;
- &lt;bar&gt;1&lt;/bar&gt;
- &lt;/foo&gt;
-elem.bar = 2;</pre>
-<p>会将原来的值 1 改成 2。</p>
-<p>你可以用 delete 命令删除一个子节点。</p>
-<pre class="brush: js">var elem = &lt;foo&gt;
- &lt;bar/&gt;
- &lt;baz/&gt;
- &lt;/foo&gt;
-delete elem.bar;</pre>
-<p>只剩下</p>
-<p><code>&lt;foo&gt;<br>
-   &lt;baz/&gt;<br>
- &lt;/foo&gt;</code></p>
-<p>点(.)操作符还能用于替换特定的子节点。</p>
-<pre class="brush: js">var elem1 = &lt;foo&gt;
- &lt;bar/&gt;
- &lt;/foo&gt;;
-var elem2 = &lt;red&gt;
- &lt;blue/&gt;
- &lt;/red&gt;;
-elem1.bar = elem2;</pre>
-<p>用 elem2 的全部内容替换 &lt;bar/&gt; 元素。</p>
-<p><code>&lt;foo&gt;<br>
-   &lt;red&gt;<br>
-     &lt;blue/&gt;<br>
-   &lt;/red&gt;<br>
- &lt;foo&gt;</code></p>
-<h2 id="XML_列表">XML 列表</h2>
-<p>许多时候,一个元素会有两个或多个相同类型的子节点。在这种情况下,访问 foo.bar 将返回一个XML 列表对象,包含所有类型为“bar”的子节点。注意:在使用 . 操作符时,判断它是返回单个元素还是一个 XML 列表,这是你的责任。在返回这些性质时,E4X 的行为并没有区别。</p>
-<p>XML 列表的行为就像是一个数组。</p>
-<pre class="brush: js">var element = &lt;foo&gt;
- &lt;bar baz="1"&gt;red&lt;/bar&gt;
- &lt;bar baz="2"&gt;blue&lt;/bar&gt;
- &lt;/foo&gt;;
-var list = element.bar;
-list.length(); // returns 2
-list[0]; // the first bar element
-list[1]; // the second bar element
-</pre>
-<p>需要注意,这个列表时可修改的,在它上面做的修改都会反映到原始的 XML 文档中。</p>
-<pre class="brush: js">list[1] = "green";</pre>
-<p>XML 文档被修改为:</p>
-<p><code>&lt;foo&gt;<br>
-   &lt;bar baz="1"&gt;red&lt;/bar&gt;<br>
-   &lt;bar baz="2"&gt;green&lt;/bar&gt;<br>
- &lt;/foo&gt;</code></p>
-<h2 id="特殊类型的节点">特殊类型的节点</h2>
-<p>XML 对象有一些方法可以访问 XML 列表中的通用类型节点。</p>
-<pre class="brush: js">var a = &lt;foo&gt; Some text &lt;bar&gt;not text&lt;/bar&gt; More text &lt;/foo&gt;;
-var list = a.text();
-list.length(); // returns 2
-list[0]; // returns " Some text "
-list[1]; // returns " More text "</pre>
-<p>你同样可以访问注释节点:</p>
-<pre class="brush: js">XML.ignoreComments = false;
-var a = &lt;foo&gt; Some &lt;!-- abc --&gt; text &lt;/foo&gt;;
-var comments = a.comments();
-alert(comments[0]); // Returns &lt;!-- abc --&gt;</pre>
-<p>星号(*)选择器将返回 XML 列表的所有子节点。</p>
-<pre class="brush: js">var a = &lt;foo&gt;
- &lt;bar/&gt;
- &lt;baz/&gt;
- &lt;/foo&gt;;
-var list = a.*;
-list.length(); // returns 2
-</pre>
-<p>元素属性</p>
-<p>很多 XML 元素都有赋有特定值的属性。例如:</p>
-<p><code>&lt;pets&gt;<br>
-   &lt;dog color="brown"&gt;Fido&lt;/dog&gt;<br>
-   &lt;cat color="grey"&gt;Fluffy&lt;/cat&gt;<br>
- &lt;/pets&gt;</code></p>
-<p>E4X 运行你用 .@ 操作符来反问这些特定元素的属性。最基本的情况如下例所示:</p>
-<pre class="brush: js"> var element = &lt;foo bar="1"/&gt;
- element.@bar = 2;</pre>
-<p>它将生成:</p>
-<p><code>&lt;foo bar="2"/&gt;</code></p>
diff --git a/files/zh-cn/archive/web/e4x_tutorial/descendants_and_filters/index.html b/files/zh-cn/archive/web/e4x_tutorial/descendants_and_filters/index.html
deleted file mode 100644
index fbf89a871f..0000000000
--- a/files/zh-cn/archive/web/e4x_tutorial/descendants_and_filters/index.html
+++ /dev/null
@@ -1,27 +0,0 @@
----
-title: Descendants and Filters
-slug: Archive/Web/E4X_tutorial/Descendants_and_Filters
-translation_of: Archive/Web/E4X_tutorial/Descendants_and_Filters
----
-<h2 id="访问后代节点">访问后代节点</h2>
-<p>很多时候,你感兴趣的节点往往不是 XML 根节点的子节点,而是嵌套在多层下的后代节点。你可以使用 .. 操作符访问任意深度的节点,或者使用 descendants 性质。例如:</p>
-<pre class="brush: js">var element = &lt;pets&gt;
- &lt;dogs&gt;
- &lt;fido color="red"/&gt;
- &lt;spike color="blue"/&gt;
- &lt;/dogs&gt;
- &lt;/pets&gt;;
-element..fido.@color = "green";
-element..spike.@color = "purple";
-</pre>
-<p>两只宠物狗的颜色都做了改变。</p>
-<p>点(.)操作符的所有规则都适用于 .. 操作符。那就是说,如果有多个请求的类型,就会返回一个 XML 后代的列表。星号(*)选择器会返回 XML 列表的所有后代。</p>
-<h2 id="过滤器">过滤器</h2>
-<p>在很多情况下,尤其是用 * 选择器时,你并不想要处理 . 或 .. 操作符返回的所有节点。为了只处理其中特定的子集,可以将筛选条件放到 . 操作符后面的圆括号里。</p>
-<pre class="brush: js">var element = &lt;dogs&gt;
- &lt;fido color="brown"/&gt;
- &lt;spike color="black"/&gt;
- &lt;killer color="brown"/&gt;
- &lt;/dogs&gt;;
-var list = element.*.(@color == "brown");</pre>
-<p>本来,element.* 返回一个包含三只狗的列表。但其中只有 fido 和 killer 的颜色是褐色的。因此,该过来条件创建了一个只包含 fido 和 killer 的列表。</p>
diff --git a/files/zh-cn/archive/web/e4x_tutorial/index.html b/files/zh-cn/archive/web/e4x_tutorial/index.html
deleted file mode 100644
index 4dac9ce0e8..0000000000
--- a/files/zh-cn/archive/web/e4x_tutorial/index.html
+++ /dev/null
@@ -1,39 +0,0 @@
----
-title: E4X教程
-slug: Archive/Web/E4X_tutorial
-translation_of: Archive/Web/E4X_tutorial
----
-<p></p><div class="prevnext" style="text-align: right;">
- <p><a href="/zh-CN/docs/cn/E4X_Tutorial/Introduction">下一页 »</a></p>
-</div><p></p>
-
-<div class="warning">
-<p>警告:E4X已废弃。 默认情况下,Firefox 16中的内容将禁用它,Firefox 17中的Chrome默认禁用,Firefox 18中将其删除。请使用DOMParser / DOMSerializer或非本机JXON算法。</p>
-</div>
-
-<h2 id="Overview" name="Overview">概述</h2>
-
-<p>本教程带你走入<strong>E4X (EcmaScript for XML)基本语法</strong>. 通过使用E4X,程序员可以通过一个类似JavaScript编程的语法来操作XML文档。</p>
-
-<h2 id="Subjects" name="Subjects">科目</h2>
-
-<ul>
- <li><a href="/cn/E4X_Tutorial/Introduction" title="cn/E4X Tutorial/Introduction">简介</a></li>
- <li><a href="/cn/E4X_Tutorial/Accessing_XML_children" title="cn/E4X_Tutorial/Accessing_XML_children">访问XML子节点</a></li>
- <li><a href="/cn/E4X_Tutorial/Descendants_and_Filters" title="cn/E4X_Tutorial/Descendants_and_Filters">子孙和过滤器</a></li>
- <li><a href="/cn/E4X_Tutorial/Namespaces" title="cn/E4X Tutorial/Namespaces">命名空间</a></li>
- <li><a href="/cn/E4X_Tutorial/The_global_XML_object" title="cn/E4X_Tutorial/The_global_XML_object">全局XML对象</a></li>
-</ul>
-
-<h2 id="See_also" name="See_also">另请参阅</h2>
-
-<ul>
- <li><a href="/cn/E4X" title="cn/E4X">E4X</a></li>
- <li><a href="/cn/E4X/Processing_XML_with_E4X" title="cn/E4X/Processing_XML_with_E4X">使用E4X处理XML</a></li>
-</ul>
-
-<p></p><div class="prevnext" style="text-align: right;">
- <p><a href="/zh-CN/docs/E4X_Tutorial:Introduction">下一页 »</a></p>
-</div><p></p>
-
-<p></p>
diff --git a/files/zh-cn/archive/web/e4x_tutorial/introduction/index.html b/files/zh-cn/archive/web/e4x_tutorial/introduction/index.html
deleted file mode 100644
index 2c0a2f7a76..0000000000
--- a/files/zh-cn/archive/web/e4x_tutorial/introduction/index.html
+++ /dev/null
@@ -1,64 +0,0 @@
----
-title: Introduction
-slug: Archive/Web/E4X_tutorial/Introduction
-tags:
- - E4X
- - JavaScript
- - Tutorial
-translation_of: Archive/Web/E4X_tutorial/Introduction
----
-<h2 id="基本语法">基本语法</h2>
-<p>如果启用了 E4X,基本的 XML 元素就是有效的语法。例如:</p>
-<pre class="brush: js">var element = &lt;foo/&gt;
- </pre>
-<p>在开启了 E4X 的浏览器里完全有效。</p>
-<p>变量的声明也不局限于单个元素,并且和 JavaScript 一样可以扩多行。</p>
-<pre class="brush: js">var element2 = &lt;foo&gt;
- &lt;bar/&gt;
- &lt;/foo&gt;
-</pre>
-<p>此外,和一般的 XML 文档一样,你能给一个元素指定属性。</p>
-<pre class="brush: js">var element3 = &lt;foo baz="1"/&gt;
- </pre>
-<p>操作元素</p>
-<p>E4X 的目标是为 JavaScript 程序员提供一个简单的方法来操作 XML 文档,而无需通过 DOM 接口。不过,很多你在 DOM 中用过的函数也能用到 E4X 中。最基本的就是 appendChild:</p>
-<pre class="brush: js">var element1 = &lt;foo/&gt;
-var element2 = &lt;bar/&gt;
-element1.appendChild(element2);
-</pre>
-<p>它会产生你期望的正确的 XML 文档:</p>
-<p><code>&lt;foo&gt;<br>
-   &lt;bar/&gt;<br>
- &lt;/foo&gt; </code></p>
-<p><code>JavaScript 变量</code></p>
-<p><code>当 XML 文档需要和 JavaScript 做紧密交互时,E4X 真正强大的地方才得以彰显。通过特定的语法,我们能将 JavaScript 变量的值赋给 E4X 元素。这是用大括号({})标记。</code></p>
-<pre class="brush: js"><code>var a = 2;
-var b = &lt;foo&gt;{a}&lt;/foo&gt;;
-</code></pre>
-<p><code>创建了一段 XML 文档,内容为 &lt;foo&gt;2&lt;/foo&gt;。</code></p>
-<p><code>你也可以将大括号标记用于元素的属性(名字或值)。例如:</code></p>
-<pre class="brush: js"><code>var a = 2;
-var b = 'bar';
-var c = &lt;foo {b}={a}&gt;"hi"&lt;/foo&gt;;</code></pre>
-<p><code>创建的 XML 稍有不同:&lt;foo bar="2"&gt;"hi"&lt;/foo&gt;。</code></p>
-<p><code>注意:XML 元素只接受文本作为他们的值。大括号标记真正发生的是调用变量的 toString 方法,并将返回值填到相应位置。例如:</code></p>
-<pre class="brush: js"><code>var a = {foo: 1};
-var b = &lt;bar&gt;{a}&lt;/bar&gt;</code></pre>
-<p><code>实际上产生的文档是 &lt;bar&gt;[object Object]&lt;/bar&gt;。</code></p>
-<h2 id="在内容中使用内联函数"><code>在内容中使用内联函数</code></h2>
-<p><code>虽然大括号限定执行单条语句,但通过匿名函数内联可以执行一些额外的处理:</code></p>
-<pre class="brush: js"><code>var a = 'foo';
-var b = &lt;bar&gt;{function () {var c = a.toUpperCase(); var d = 5 * 5; return c + d;}()}&lt;/bar&gt;</code></pre>
-<p><code>上述代码产生:&lt;bar&gt;FOO25&lt;/bar&gt;</code></p>
-<p><code>该用法更多的讨论请参加 <a href="/en/E4X_for_templating#Inline_functions" title="en/E4X_for_templating#Inline_functions">E4X for templating</a> 。</code></p>
-<h2 id="序列化"><code>序列化</code></h2>
-<p><code>E4X 最强大的工具就是简单地调用 .toXMLString() 就可以将整个 XML 文档(或其中部分)序列化到字符串中。</code></p>
-<pre class="brush: js"><code>var element1 = &lt;foo/&gt;;
-var element2 = &lt;bar/&gt;;
-element1.apppendChild(element2);
-element1.toXMLString();</code></pre>
-<p><code>输出为:</code></p>
-<p><code><code>&lt;foo&gt;<br>
-   &lt;bar/&gt;<br>
- &lt;/foo&gt;</code></code></p>
-<p><code>本例使用 toString() 也能达到相同效果,不过在一个只有文本内容的元素上调用 toString() 将之产生文本内容(例如,&lt;foo&gt;abc&lt;/foo&gt;.toString(); 会只产生 'abc')。</code></p>
diff --git a/files/zh-cn/archive/web/e4x_tutorial/namespaces/index.html b/files/zh-cn/archive/web/e4x_tutorial/namespaces/index.html
deleted file mode 100644
index 8a2fc96063..0000000000
--- a/files/zh-cn/archive/web/e4x_tutorial/namespaces/index.html
+++ /dev/null
@@ -1,33 +0,0 @@
----
-title: Namespaces
-slug: Archive/Web/E4X_tutorial/Namespaces
-translation_of: Archive/Web/E4X_tutorial/Namespaces
----
-<h2 id="E4X_与_命令空间">E4X 与 命令空间</h2>
-<p>通常情况下,XML 文档包含来自多种命令空间的元素。你可以通过声明为你的 E4X 对象设置默认的命名空间。</p>
-<pre class="brush: js">default xml namespace = "http://www.w3.org/1999/xhtml";
-</pre>
-<p>通过重复的声明,你可以随时更改相同范围内 E4X 的命名空间。</p>
-<pre class="brush: js">default xml namespace = "http://www.w3.org/1999/xhtml";
-var a = &lt;p&gt;Some text&lt;/p&gt;;
-default xml namespace = "http://www.mozilla.org/keymaster/gat...re.is.only.xul";
-var b = &lt;label&gt;More text&lt;/label&gt;;
-a.appendChild(b);
-</pre>
-<p>得出</p>
-<p><code>&lt;p xmlns="<a class="external" href="http://www.w3.org/1999/xhtml" rel="freelink">http://www.w3.org/1999/xhtml</a>"&gt;<br>
-   Some text<br>
-   &lt;label xmlns="<a class="external" href="http://www.mozilla.org/keymaster/gat...re.is.only.xul" rel="freelink">http://www.mozilla.org/keymaster/gat...re.is.only.xul</a>"&gt;More text&lt;/label&gt;<br>
- &lt;/p&gt; </code></p>
-<h2 id="name()">name()</h2>
-<p>在 XML 对象上调用 name() 会返回一个 QName 对象(Qualified Name)。QName 在支持 E4X 的 JavaScript 实现中是一个全局的构造函数。QName 对象有两个特别重要的属性:localName 返回元素的名字,且没有任何命名空间前缀;uri 返回元素所在的命名空间。</p>
-<pre class="brush: js">var info = a.name();
-info.localName; // returns 'p'.
-info.uri; // returns "http://www.w3.org/1999/xhtml"</pre>
-<p>没有在任何命令空间的元素,他们的 uri 是一个空字符串。</p>
-<p>Namespace 全局构造函数和 QName 非常相似。Namespace 的不同之处是 toString 方法,以及 Namespace 用 prefix 属性来代替 localName 属性<sup>[1]</sup> 。</p>
-<p>关于 E4X 的命名空间,更多的内容请参见 <a href="/cn/E4X/Processing_XML_with_E4X#Handling_namespaces" title="cn/E4X/Processing_XML_with_E4X#Handling_namespaces">Processing XML with E4X</a> 。</p>
-<h2 id="译者注">译者注</h2>
-<ol>
- <li>原文中没有详细讲,获得 Namespace 对象的方法是调用 .namespace()。其中 QName 的 toString 方法会输出 Namespace::name 的形式,而 Namespace 的 toString 只会输出命名空间。</li>
-</ol>
diff --git a/files/zh-cn/archive/web/e4x_tutorial/the_global_xml_object/index.html b/files/zh-cn/archive/web/e4x_tutorial/the_global_xml_object/index.html
deleted file mode 100644
index 910b422ada..0000000000
--- a/files/zh-cn/archive/web/e4x_tutorial/the_global_xml_object/index.html
+++ /dev/null
@@ -1,55 +0,0 @@
----
-title: The global XML object
-slug: Archive/Web/E4X_tutorial/The_global_XML_object
-translation_of: Archive/Web/E4X_tutorial/The_global_XML_object
----
-<h2 id="全局_XML_对象">全局 XML 对象</h2>
-<p>E4X-capable JavaScript 引擎在全局对象上放了一个新的属性。XML 对象有许多属性允许你定制解析和序列化 E4X。XML 元素从他们创建开始就记住 XML 对象的设置。</p>
-<h2 id="扩展_XML.prototype">扩展 XML.prototype</h2>
-<p>XML.prototype 和 XMLList.prototype(XMLList.prototype 实际上就是 XML.prototype)不能像其他构造器(例如 Object)一样扩展。你只能在 XML.prototype 里定义方法,而不能定义字段。要向 XML.prototype 添加一个方法,则要定义 XML.prototype.function::methodName 或 XML.prototype.funciton::[methodNameString]。下例定义 fooCount() 方法,返回 XML 中 &lt;foo&gt; 元素的个数:</p>
-<p> </p>
-<pre class="brush: js">XML.prototype.function::fooCount = function fooCount() {
- return this..foo.length();
-};
-&lt;foobar&gt;&lt;foo/&gt;&lt;foo/&gt;&lt;foo/&gt;&lt;/foobar&gt;.fooCount() // returns 3</pre>
-<p> </p>
-<h2 id="ignoreComments">ignoreComments</h2>
-<p>默认为 true。该属性告诉 E4X 在序列化和筛选时忽略注释节点。即当 ignoreComments 为 ture 时 .comments() 返回空。观察如下例子:</p>
-<p> </p>
-<pre class="brush: js">var element = &lt;foo&gt;
- &lt;!-- my comment --&gt;
- &lt;bar/&gt;
- &lt;/foo&gt;;
-element.comments().length(); // returns 0
-element.toXMLString(); // returns &lt;foo&gt;&lt;bar/&gt;&lt;/foo&gt;
-XML.ignoreComments = false;
-element = &lt;foo&gt;
- &lt;!-- my comment --&gt;
- &lt;bar/&gt;
- &lt;/foo&gt;;
-element.comments().length(); // returns 1
-element.toXMLString(); // returns &lt;foo&gt;&lt;!-- my comment --&gt;&lt;bar/&gt;&lt;/foo&gt;</pre>
-<p> </p>
-<h2 id="ignoreProcessingInstructions">ignoreProcessingInstructions</h2>
-<p>默认为 ture。该属性告诉 E4X 在序列化和筛选时忽略 XML 中的处理指令。例如:</p>
-<p> </p>
-<pre class="brush: js">var element = &lt;foo&gt;
- &lt;?process x="true"?&gt;
- &lt;bar/&gt;
- &lt;?process x="false"?&gt;
- &lt;/foo&gt;;
-element.toXMLString(); // returns &lt;foo&gt;&lt;bar/&gt;&lt;/foo&gt;
-XML.ignoreProcessingInstructions = false;
-var element = &lt;foo&gt;
- &lt;?process x="true"?&gt;
- &lt;bar/&gt;
- &lt;?process x="false"?&gt;
- &lt;/foo&gt;;
-element.toXMLString(); // returns &lt;foo&gt;&lt;?process x="true"?&gt;&lt;bar/&gt;&lt;?process x="false"?&gt;&lt;/foo&gt;</pre>
-<p> </p>
-<h2 id="ignoreWhitespace">ignoreWhitespace</h2>
-<p>默认为 true。忽略节点之间以及节点文本头尾两端的空白,而其他的则被解析为文本节点或作为文本节点的一部分。</p>
-<h2 id="prettyPrinting">prettyPrinting</h2>
-<p>默认是 true。为 true 时,toXMLString() 序列化 E4X 对象时会包含换行和缩进。</p>
-<h2 id="prettyIndent">prettyIndent</h2>
-<p>默认值是 2。代表 XML 树每层缩进的空格数。如果 prettyPrinting 是 false 则忽略。</p>
diff --git a/files/zh-cn/archive/web/index.html b/files/zh-cn/archive/web/index.html
deleted file mode 100644
index a6edb0c862..0000000000
--- a/files/zh-cn/archive/web/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: Archived open Web documentation
-slug: Archive/Web
-tags:
- - Archived
- - NeedsTranslation
- - TopicStub
- - Web
-translation_of: Archive/Web
----
-<p>The documentation listed below is archived, obsolete material about open Web topics.</p>
-<p></p><dl><dt class="landingPageList"><a href="/zh-CN/docs/E4X-840092-dup">E4X</a></dt><dd class="landingPageList"><strong>ECMAScript for XML</strong> (<strong>E4X</strong>) is a programming language extension that adds native XML support to <a href="/zh-CN/JavaScript" title="zh-CN/JavaScript">JavaScript</a>. It does this by providing access to the XML document in a form that feels natural for ECMAScript programmers. The goal is to provide an alternative, simpler syntax for accessing XML documents than via <a href="/zh-CN/DOM" title="zh-CN/DOM">DOM</a> interfaces. A valid alternative to E4X is a non-native <a href="/zh-CN/JXON" title="zh-CN/JXON">JXON algorithm</a>.</dd><dt class="landingPageList"><a href="/zh-CN/docs/Archive/Web/E4X_tutorial">E4X教程</a></dt><dd class="landingPageList">本教程带你走入<strong>E4X (EcmaScript for XML)基本语法</strong>. 通过使用E4X,程序员可以通过一个类似JavaScript编程的语法来操作XML文档。</dd><dt class="landingPageList"><a href="/zh-CN/docs/Archive/Web/LiveConnect">LiveConnect概述</a></dt><dd class="landingPageList">这一章描述了使用 <a href="/zh-CN/docs/LiveConnect" title="zh-CN/docs/LiveConnect">LiveConnect  </a>技术来使JavaScript和Java能够互相通信。本章假设你熟悉Java编程。</dd></dl><p></p>
diff --git a/files/zh-cn/archive/web/indexeddb_api_using_javascript_generators_in_firefox/index.html b/files/zh-cn/archive/web/indexeddb_api_using_javascript_generators_in_firefox/index.html
deleted file mode 100644
index 33fb51b750..0000000000
--- a/files/zh-cn/archive/web/indexeddb_api_using_javascript_generators_in_firefox/index.html
+++ /dev/null
@@ -1,60 +0,0 @@
----
-title: 在 Firefox 中使用 JavaScript Generators
-slug: Archive/Web/IndexedDB_API_Using_JavaScript_Generators_in_Firefox
-translation_of: Archive/Web/IndexedDB_API_Using_JavaScript_Generators_in_Firefox
----
-<div class="warning"><strong>警告:</strong> 此项技术仅对 Firefox 浏览器生效,而对 IE、 Chrome、 Safari 等浏览器无效。</div>
-
-<p>生成器(generators)可用于简化 Firefox 浏览器中的异步代码,需使用 JavaScript 1.7 或更高版本。 您可以按下列方式引入 HTML:</p>
-
-<pre class="brush: js">&lt;script type="text/javascript;version=1.7" src="myScript.js"&gt;&lt;/script&gt;</pre>
-
-<p>一个 <code>myScript.js</code> 文件可能是像这样的:</p>
-
-<pre class="brush: js">// 需要将生成器(generator)存储在全局变量中。
-var generator;
-
-// 通过简单的事件侦听器将接收到的事件传递给生成器。
-function grabEvent(event) {
- generator.send(event);
-}
-
-// 关闭生成器,但必须在生成器外部进行,所以我们使用 setTimeout 函数
-function closeGenerator() {
- setTimeout(function() {
- generator.close();
- }, 0);
-}
-
-// 主函数
-function databaseOperation() {
- mozIndexedDB.open("MyTestDatabase").onsuccess = grabEvent;
- var event = yield;
-
- var db = event.target.result;
-
- if (db.version != "1.0") {
- db.setVersion("1.0").onsuccess = grabEvent;
- event = yield;
-
- var transaction = event.transaction;
- db.createObjectStore("stuff");
-
- transaction.oncomplete = grabEvent;
- yield;
-  }
-
- db.transaction(["stuff"]).objectStore("stuff").get("foo").onsuccess = grabEvent;
- event = yield;
-
- alert("Got result: " + event.target.result);
-
- // 完成。
- closeGenerator();
-
- // 始终在末尾额外使用一次 yield ,否则您将看到 StopIteration 异常。
- yield;
-}
-
-generator = databaseOperation();
-generator.next();</pre>
diff --git a/files/zh-cn/archive/web/javascript/handler.enumerate/index.html b/files/zh-cn/archive/web/javascript/handler.enumerate/index.html
deleted file mode 100644
index 9a68adbf65..0000000000
--- a/files/zh-cn/archive/web/javascript/handler.enumerate/index.html
+++ /dev/null
@@ -1,114 +0,0 @@
----
-title: handler.enumerate()
-slug: Archive/Web/JavaScript/handler.enumerate
-translation_of: Archive/Web/JavaScript/handler.enumerate
----
-<div>{{JSRef}} {{obsolete_header}}</div>
-
-<p>代理方法<strong><code>handler.enumerate()</code></strong>决定了被代理对象在{{jsxref("Statements/for...in", "for...in")}}中的行为。不过这个方法已经在ES2016标准中被移除了。</p>
-
-<h2 id="语法">语法</h2>
-
-<pre class="brush: js notranslate">var p = new Proxy(target, {
- enumerate(target) {
- }
-});
-</pre>
-
-<h3 id="参数">参数</h3>
-
-<p>下列参数将会被用以调用 <code>enumerate</code> 方法。this将会指向处理器对象。</p>
-
-<dl>
- <dt><code>target</code></dt>
- <dd>被代理的目标对象。</dd>
-</dl>
-
-<h3 id="Return_value">Return value</h3>
-
-<p>该方法应当返回一个<a href="/zh-CN/docs/Web/JavaScript/Guide/The_Iterator_protocol">迭代器</a>对象。</p>
-
-<h2 id="描述">描述</h2>
-
-<p><code><strong>handler.enumerate</strong></code> 方法决定了被代理对象在{{jsxref("Statements/for...in", "for...in")}}时的行为。</p>
-
-<h3 id="触发条件">触发条件</h3>
-
-<p>这些操作可以触发这个方法。</p>
-
-<ul>
- <li>for...in: <code>for (var name in proxy) {...}</code></li>
- <li>{{jsxref("Reflect.enumerate()")}}</li>
-</ul>
-
-<h3 id="Invariants">Invariants</h3>
-
-<p>If the following invariants are violated, the proxy will throw a {{jsxref("TypeError")}}:</p>
-
-<ul>
- <li>The <code>enumerate</code> method must return an object.</li>
-</ul>
-
-<h2 id="Examples">Examples</h2>
-
-<p>The following code traps {{jsxref("Statements/for...in", "for...in")}} statements.</p>
-
-<pre class="brush: js notranslate">var p = new Proxy({}, {
- enumerate(target) {
- console.log('called');
- return ['a', 'b', 'c'][Symbol.iterator]();
- }
-});
-
-for (var x in p) { // "called"
- console.log(x); // "a"
-} // "b"
- // "c"
-</pre>
-
-<p>The following code violates the invariant.</p>
-
-<pre class="brush: js notranslate">var p = new Proxy({}, {
- enumerate(target) {
- return 1;
- }
-});
-
-for (var x in p) {} // TypeError is thrown
-</pre>
-
-<p>Note: Both examples make use of the shorthand syntax for <a href="/en-US/docs/Web/JavaScript/Reference/Functions/Method_definitions">method definitions</a>.</p>
-
-<h2 id="Specifications">Specifications</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('ES2015', '#sec-proxy-object-internal-methods-and-internal-slots-enumerate', '[[Enumerate]]')}}</td>
- <td>{{Spec2('ES2015')}}</td>
- <td>Initial definition. Removed in ECMAScript 2016.</td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Browser_compatibility">Browser compatibility</h2>
-
-<div>
-
-
-<p>{{Compat("javascript.builtins.Proxy.handler.enumerate")}}</p>
-</div>
-
-<h2 id="See_also">See also</h2>
-
-<ul>
- <li>{{jsxref("Proxy")}}</li>
- <li>{{jsxref("Proxy.handler", "handler")}}</li>
- <li>{{jsxref("Statements/for...in", "for...in")}} statements</li>
- <li>{{jsxref("Reflect.enumerate()")}}</li>
-</ul>
diff --git a/files/zh-cn/archive/web/javascript/index.html b/files/zh-cn/archive/web/javascript/index.html
deleted file mode 100644
index 4687b7bf23..0000000000
--- a/files/zh-cn/archive/web/javascript/index.html
+++ /dev/null
@@ -1,12 +0,0 @@
----
-title: JavaScript
-slug: Archive/Web/JavaScript
-translation_of: Archive/Web/JavaScript
----
-<div class="hidden">{{JSRef}}</div>
-
-<p>{{Obsolete_Header}}</p>
-
-<p class="summary">Obsolete JavaScript features and unmaintained docs</p>
-
-<p>{{SubpagesWithSummaries}}</p>
diff --git a/files/zh-cn/archive/web/javascript/legacy_generator_function/index.html b/files/zh-cn/archive/web/javascript/legacy_generator_function/index.html
deleted file mode 100644
index d4d213cc98..0000000000
--- a/files/zh-cn/archive/web/javascript/legacy_generator_function/index.html
+++ /dev/null
@@ -1,54 +0,0 @@
----
-title: 旧式生成器函数
-slug: Archive/Web/JavaScript/Legacy_generator_function
-tags:
- - 生成器函数
-translation_of: Archive/Web/JavaScript/Legacy_generator_function
----
-<div class="warning">.旧式生成器函数是一个SpiderMonkey专有特性,将在未来移除。从未来考虑,建议使用{{jsxref("Operators/function*", "function* 表达式")}}</div>
-
-<div>{{jsSidebar("Operators")}}</div>
-
-<p><strong><code>function</code></strong> 关键字可以用于在表达式中定义旧式的生成器函数。为使定义的函数为一个旧式的生成器函数,该函数的函数体中需要至少包含一个 {{jsxref("Operators/yield", "yield")}} 表达式。</p>
-
-<h2 id="语法">语法</h2>
-
-<pre class="syntaxbox">function [<em>name</em>]([<em>param1</em>[, <em>param2[</em>, ..., <em>paramN</em>]]]) {
- <em>statements</em>
-}</pre>
-
-<h3 id="参数">参数</h3>
-
-<dl>
- <dt><code>name</code></dt>
- <dd>函数名。 该参数可以被省略, 这种情况下将创建一个<em>匿名函数 (anonymous)</em>. 此名字仅可在函数体内部引用。</dd>
- <dt><code>paramN</code></dt>
- <dd>将被传入此函数的一个参数。一个函数可以最多拥有255个参数。</dd>
- <dt><code>statements</code></dt>
- <dd>构成函数体的表达式。在表达式中需要至少包含一个 {{jsxref("Operators/yield", "yield")}} 表达式。</dd>
-</dl>
-
-<h2 id="描述">描述</h2>
-
-<p>关于此语法的用法说明,参见 <a href="/en-US/docs/JavaScript/Guide/Iterators_and_Generators">迭代器 (Iterators) 与生成器 (Generators)</a> 页面。</p>
-
-<h2 id="浏览器兼容性">浏览器兼容性</h2>
-
-<p>Supported nowhere</p>
-
-<h2 id="相关链接">相关链接</h2>
-
-<ul>
- <li>{{jsxref("Generator","生成器 (Generator)")}}</li>
- <li><a href="/en-US/docs/Web/JavaScript/Reference/Statements/Legacy_generator_function">旧式生成器函数</a></li>
- <li><a href="/en-US/docs/Web/JavaScript/Guide/The_legacy_Iterator_protocol">旧式迭代器协议</a></li>
- <li>{{jsxref("Operators/yield", "yield")}}</li>
- <li><a href="/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope">函数与函数作用域</a></li>
- <li>{{jsxref("Statements/function", "function")}}</li>
- <li>{{jsxref("Operators/function", "function 表达式")}}</li>
- <li>{{jsxref("Function", "函数")}}</li>
- <li>{{jsxref("Statements/function*", "function*")}}</li>
- <li>{{jsxref("Operators/function*", "function* 表达式")}}</li>
- <li>{{jsxref("GeneratorFunction","生成器 (Generator) 函数")}}</li>
- <li><a href="/en-US/docs/Web/JavaScript/Guide/The_Iterator_protocol">迭代器 (Iterator) 协议 </a></li>
-</ul>
diff --git a/files/zh-cn/archive/web/javascript/legacy_generator_function_statement/index.html b/files/zh-cn/archive/web/javascript/legacy_generator_function_statement/index.html
deleted file mode 100644
index e8c8f209a9..0000000000
--- a/files/zh-cn/archive/web/javascript/legacy_generator_function_statement/index.html
+++ /dev/null
@@ -1,65 +0,0 @@
----
-title: 遗留的生成器函数
-slug: Archive/Web/JavaScript/Legacy_generator_function_statement
-tags:
- - JavaScript
- - 参考
- - 过时
- - 非标准
-translation_of: Archive/Web/JavaScript/Legacy_generator_function_statement
----
-<div>{{JSSidebar("Statements")}}{{Non-standard_Header}}{{Obsolete_Header("gecko58")}}
-<div class="warning">
-<p>遗留的生成器函数是 SpiderMonkey 专有特性,已在 Firefox 58+ 中被移除。请考虑使用 {{JSxRef("Statements/function*", "function*")}}。</p>
-</div>
-
-<p><strong>遗留的生成器函数声明</strong>使用特殊的参数声明遗留的生成器函数。</p>
-
-<p>也可以使用带有 <code>functionBody</code>、至少一个 {{jsxref("Operators/yield", "yield")}} 表达式,和{{jsxref("Operators/Legacy_generator_function", "遗留的生成器函数表达式")}},配合 {{JSxRef("Function")}} 构造器,来定义遗留的生成器函数。</p>
-
-<h2 id="语法">语法</h2>
-
-<pre class="syntaxbox">function <em>name</em>([<em>param</em>,[, <em>param</em>,[..., <em>param</em>]]]) {
- [<em>statements</em>]
-}
-</pre>
-
-<dl>
- <dt><code>name</code></dt>
- <dd>函数名。</dd>
-</dl>
-
-<dl>
- <dt><code>param</code></dt>
- <dd>传入函数的参数名,一个函数最多有 255 个参数。</dd>
-</dl>
-
-<dl>
- <dt><code>statements</code></dt>
- <dd>构成函数体的语句。应至少含有一个 {{jsxref("Operators/yield", "yield")}} 表达式。</dd>
-</dl>
-
-<h2 id="描述">描述</h2>
-
-<p>用法概述可在<a href="/zh-CN/docs/JavaScript/Guide/Iterators_and_Generators">迭代器和生成器</a>页面上查看。</p>
-
-<h2 id="浏览器兼容性">浏览器兼容性</h2>
-Supported nowhere.
-
-<h2 id="参考">参考</h2>
-
-<ul>
- <li>{{jsxref("Generator")}}</li>
- <li><a href="/zh-CN/docs/Web/JavaScript/Reference/Operators/Legacy_generator_function">遗留的函数生成器表达式</a></li>
- <li><a href="/zh-CN/docs/Web/JavaScript/Guide/The_legacy_Iterator_protocol">遗留的迭代器协议</a></li>
- <li>{{jsxref("Operators/yield", "yield")}}</li>
- <li><a href="/zh-CN/docs/Web/JavaScript/Reference/Functions_and_function_scope">函数和函数作用域</a></li>
- <li>{{jsxref("Statements/function", "function")}}</li>
- <li>{{jsxref("Operators/function", "function 表达式")}}</li>
- <li>{{jsxref("Function")}}</li>
- <li>{{jsxref("Statements/function*", "function*")}}</li>
- <li>{{jsxref("Operators/function*", "function* 表达式")}}</li>
- <li>{{jsxref("GeneratorFunction")}}</li>
- <li><a href="/zh-CN/docs/Web/JavaScript/Guide/The_Iterator_protocol">迭代器协议</a></li>
-</ul>
-</div>
diff --git a/files/zh-cn/archive/web/javascript/microsoft_extensions/activexobject/index.html b/files/zh-cn/archive/web/javascript/microsoft_extensions/activexobject/index.html
deleted file mode 100644
index b275c9676b..0000000000
--- a/files/zh-cn/archive/web/javascript/microsoft_extensions/activexobject/index.html
+++ /dev/null
@@ -1,92 +0,0 @@
----
-title: ActiveXObject
-slug: Archive/Web/JavaScript/Microsoft_Extensions/ActiveXObject
-translation_of: Archive/Web/JavaScript/Microsoft_Extensions/ActiveXObject
----
-<div>{{JSRef}}</div>
-
-<div class="warning"><strong>警告</strong>: 该对象是微软的私有拓展名, 只在微软的IE浏览器上支持, 在win8的应用商店下载的其他浏览器应用也不被支持.</div>
-
-<p><strong><code>ActiveXObject</code> </strong>启用会返回一个自动化对象的引用</p>
-
-<p>这个对象只能用于实例化自动化对象,它没有任何成员对象.</p>
-
-<h2 id="语法">语法 </h2>
-
-<pre><code>let newObj = new ActiveXObject(<em>servername, </em><em>typename</em>[, <em>location</em>])
-</code></pre>
-
-<h3 id="参数">参数</h3>
-
-<dl>
- <dt><code>servername</code></dt>
- <dd>提供对象的应用程序的名称。</dd>
- <dt><code>typename</code></dt>
- <dd>要创建的对象的类型或类。</dd>
- <dt><code>location</code> {{optional_inline}}</dt>
- <dd>要创建对象的网络服务器的名称。</dd>
-</dl>
-
-<h2 id="备注">备注</h2>
-
-<p>自动化服务器提供至少一种类型的对象。例如,文字处理应用程序可以提供应用程序对象、文档对象和工具栏对象。</p>
-
-<p>您可以在<code>HKEY_CLASSES_ROOT</code>注册注册表项中识别主机PC上的<code>servername.typename的</code>值。下面是您可以找到的一些示例,它们要取决于你的电脑安装了哪些程序:</p>
-
-<ul>
- <li>
- <p>Excel.Application</p>
- </li>
- <li>
- <p>Excel.Chart</p>
- </li>
- <li>
- <p>Scripting.FileSystemObject</p>
- </li>
- <li>
- <p>WScript.Shell</p>
- </li>
- <li>
- <p>Word.Document</p>
- </li>
-</ul>
-
-<div class="warning">
-<p><strong>注意:</strong> ActiveX 对象可能会出现安全问题。要使用<code>ActiveXObject</code>, 你可能需要调整IE浏览器的相关安全区域的安全设置。比如说,对于本地局域网,你通常需要将自定义设置更改为"对未标记为可安全执行脚本ActiveX控件执行初始化并执行脚本"。</p>
-</div>
-
-<p>To identify members of an automation object that you can use in your code, you may need to use a COM object browser, such as the <a href="http://msdn.microsoft.com/library/d0kh9f4c.aspx">OLE/COM Object Viewer</a>, if no reference documentation is available for the Automation object.</p>
-
-<p>To create an Automation object, assign the new <code>ActiveXObject</code> to an object variable:</p>
-
-<pre class="brush: js">var ExcelApp = new ActiveXObject("Excel.Application");
-var ExcelSheet = new ActiveXObject("Excel.Sheet");
-</pre>
-
-<p>This code starts the application creating the object (in this case, a Microsoft Excel worksheet). Once an object is created, you refer to it in code using the object variable you defined. In the following example, you access properties and methods of the new object using the object variable <code>ExcelSheet</code> and other Excel objects, including the application object and the <code>ActiveSheet.Cells</code> collection.</p>
-
-<pre class="brush: js">// Make Excel visible through the Application object.
-ExcelSheet.Application.Visible = true;
-// Place some text in the first cell of the sheet.
-ExcelSheet.ActiveSheet.Cells(1,1).Value = "This is column A, row 1";
-// Save the sheet.
-ExcelSheet.SaveAs("C:\\TEST.XLS");
-// Close Excel with the Quit method on the Application object.
-ExcelSheet.Application.Quit();
-</pre>
-
-<h2 id="Requirements">Requirements</h2>
-
-<p>Supported in the following document modes: Quirks, Internet Explorer 6 standards, Internet Explorer 7 standards, Internet Explorer 8 standards, Internet Explorer 9 standards, Internet Explorer 10 standards, Internet Explorer 11 standards. Not supported in Windows 8.x Store apps.</p>
-
-<div class="note">
-<p><strong>Note:</strong> Creating an <code>ActiveXObject</code> on a remote server is not supported in Internet Explorer 9 standards mode, Internet Explorer 10 standards mode, Internet Explorer 11 standards mode, and Windows Store apps or later.</p>
-</div>
-
-<h2 id="See_also">See also</h2>
-
-<ul>
- <li><a href="/en-US/docs/Web/JavaScript/Microsoft_JavaScript_extensions">Microsoft JavaScript extensions</a></li>
- <li><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Microsoft_JavaScript_extensions/GetObject">GetObject Function</a></li>
- <li><a href="http://code.msdn.microsoft.com/Unique-Authentication-f32d2da0">Unique authentication using Magic of HTML5/WCF sample app</a></li>
-</ul>
diff --git a/files/zh-cn/archive/web/javascript/microsoft_extensions/date.getvardate/index.html b/files/zh-cn/archive/web/javascript/microsoft_extensions/date.getvardate/index.html
deleted file mode 100644
index 3587d44b2d..0000000000
--- a/files/zh-cn/archive/web/javascript/microsoft_extensions/date.getvardate/index.html
+++ /dev/null
@@ -1,40 +0,0 @@
----
-title: Date.getVarDate()
-slug: Archive/Web/JavaScript/Microsoft_Extensions/Date.getVarDate
-translation_of: Archive/Web/JavaScript/Microsoft_Extensions/Date.getVarDate
----
-<div><font><font>{{JSRef(“ Global_Objects”,“ Date”)}} {{Non-standard_Header}} {{Obsolete_Header}}</font></font>
-<div class="warning"><strong><font><font>警告:  </font></font></strong><span style="font-size: 1.125rem;"><font><font>仅Internet Explorer支持此方法。</font></font></span></div>
-</div>
-
-<p><font><font>该</font></font><strong><code>getVarDate</code><font><font>方法</font></font></strong><code>VT_DATE</code><font><font>从{{JSxRef(“ Date”)}}对象</font><font>返回</font><font>值。</font></font></p>
-
-<h2 id="句法"><font><font>句法</font></font></h2>
-
-<pre class="notranslate"><code>dateObj.getVarDate()
-</code></pre>
-
-<h3 id="参量"><font><font>参量</font></font></h3>
-
-<p><font><font>必需的  </font></font><code>dateObj</code><font><font> 引用是一个  </font></font><code>Date</code><font><font> 对象。</font></font></p>
-
-<h3 id="返回值"><font><font>返回值</font></font></h3>
-
-<p><font><font>返回VT_DATE值。</font></font></p>
-
-<h3 id="备注"><font><font>备注</font></font></h3>
-
-<p><code>getVarDate()</code><font><font>当JavaScript代码与COM对象,ActiveX对象或其他接受并返回VT_DATE格式的日期值的对象交互时,使用</font><font>此  </font><font>方法。</font><font>这些包括Visual Basic和Visual Basic脚本版(VBScript)中的对象。</font><font>返回值的实际格式取决于区域设置。</font></font></p>
-
-<h2 id="要求"><font><font>要求</font></font></h2>
-
-<p><font><font>在以下文档模式中受支持:怪癖,Internet Explorer 6标准,Internet Explorer 7标准,Internet Explorer 8标准,Internet Explorer 9标准和Internet Explorer 10标准。</font><font>Windows 8.x商店应用程序不支持。</font></font></p>
-
-<p><strong><font><font>适用于</font></font></strong><font><font>:  </font></font><a href="https://docs.microsoft.com/en-us/scripting/javascript/reference/date-object-javascript"><font><font>Date对象</font></font></a></p>
-
-<h2 id="也可以看看"><font><font>也可以看看</font></font></h2>
-
-<ul>
- <li><font><font>{{JSxRef(“ Date.getDate()”)}}</font></font></li>
- <li><font><font>{{JSxRef(“ Date.parse()”)}}</font></font></li>
-</ul>
diff --git a/files/zh-cn/archive/web/javascript/microsoft_extensions/index.html b/files/zh-cn/archive/web/javascript/microsoft_extensions/index.html
deleted file mode 100644
index a128cb7caf..0000000000
--- a/files/zh-cn/archive/web/javascript/microsoft_extensions/index.html
+++ /dev/null
@@ -1,70 +0,0 @@
----
-title: Microsoft JavaScript extensions
-slug: Archive/Web/JavaScript/Microsoft_Extensions
-tags:
- - JavaScript
- - 'JavaScript:Microsoft Extensions'
- - NeedsTranslation
- - Non-standard
- - Reference
- - TopicStub
-translation_of: Archive/Web/JavaScript/Microsoft_Extensions
----
-<div>{{JSSidebar("Microsoft Extensions")}}{{Non-standard_Header}}
-<div class="blockIndicator warning">
-<p><strong>Warning:</strong> These APIs will only work in Microsoft applications, and are not on a standards track.</p>
-</div>
-</div>
-
-<p>Microsoft browsers (Internet Explorer, and in a few cases, Microsoft Edge) support a number of special Microsoft extensions to the otherwise standard <a href="/en-US/docs/Web/JavaScript">JavaScript APIs</a>.</p>
-
-<h2 id="Objects">Objects</h2>
-
-<div class="index">
-<ul>
- <li>{{jsxref("ActiveXObject")}} {{obsolete_inline}}</li>
- <li>{{jsxref("Debug")}} {{deprecated_inline}}</li>
- <li>{{jsxref("Enumerator")}} {{obsolete_inline}}</li>
- <li>{{jsxref("VBArray")}} {{obsolete_inline}}</li>
-</ul>
-</div>
-
-<h2 id="Functions">Functions</h2>
-
-<div class="index">
-<ul>
- <li>{{jsxref("GetObject")}} {{obsolete_inline}}</li>
- <li>{{jsxref("ScriptEngine")}} {{deprecated_inline}}</li>
- <li>{{jsxref("ScriptEngineBuildVersion")}} {{deprecated_inline}}</li>
- <li>{{jsxref("ScriptEngineMajorVersion")}} {{deprecated_inline}}</li>
- <li>{{jsxref("ScriptEngineMinorVersion")}} {{deprecated_inline}}</li>
-</ul>
-</div>
-
-<h2 id="Statements">Statements</h2>
-
-<div class="index">
-<ul>
- <li><a href="/en-US/docs/Web/JavaScript/Microsoft_JavaScript_extensions/at-cc-on">@cc-on</a> {{obsolete_inline}}</li>
- <li><a href="/en-US/docs/Web/JavaScript/Microsoft_JavaScript_extensions/at-if">@if</a> {{obsolete_inline}}</li>
- <li><a href="/en-US/docs/Web/JavaScript/Microsoft_JavaScript_extensions/at-set">@set</a> {{obsolete_inline}}</li>
-</ul>
-</div>
-
-<h2 id="Other">Other</h2>
-
-<div class="index">
-<ul>
- <li><code><a href="/en-US/docs/Web/JavaScript/Microsoft_JavaScript_extensions/Date.getVarDate">Date.getVarDate()</a></code> {{obsolete_inline}}</li>
- <li><code><a href="/en-US/docs/Web/JavaScript/Microsoft_JavaScript_extensions/Error.description">Error.description</a></code> {{deprecated_inline}}</li>
- <li><code><a href="/en-US/docs/Web/JavaScript/Microsoft_JavaScript_extensions/Error.number">Error.number</a></code> {{deprecated_inline}}</li>
- <li><code><a href="/en-US/docs/Web/JavaScript/Microsoft_JavaScript_extensions/Error.stackTraceLimit">Error.stackTraceLimit</a></code> {{deprecated_inline}}</li>
-</ul>
-</div>
-
-<h2 id="See_also">See also</h2>
-
-<ul>
- <li><a href="/en-US/docs/Web/CSS/Microsoft_Extensions">Microsoft CSS Extensions</a></li>
- <li><a href="/en-US/docs/Web/API/Microsoft_API_extensions">Microsoft DOM Extensions</a></li>
-</ul>
diff --git a/files/zh-cn/archive/web/javascript/reflect.enumerate/index.html b/files/zh-cn/archive/web/javascript/reflect.enumerate/index.html
deleted file mode 100644
index e8eb0bd103..0000000000
--- a/files/zh-cn/archive/web/javascript/reflect.enumerate/index.html
+++ /dev/null
@@ -1,120 +0,0 @@
----
-title: Reflect.enumerate()
-slug: Archive/Web/JavaScript/Reflect.enumerate
-translation_of: Archive/Web/JavaScript/Reflect.enumerate
----
-<div>{{JSRef}} {{obsolete_header}}</div>
-
-<div><strong><code>Reflect.enumerate()</code></strong>静态方法通常返回目标对象自身和继承的可迭代属性的一个迭代器,在ECMAScript 2016中已被移除,在各浏览器中已被废弃。</div>
-
-<h2 id="语法">语法</h2>
-
-<pre class="syntaxbox notranslate">Reflect.enumerate(target)
-</pre>
-
-<h3 id="参数">参数</h3>
-
-<dl>
- <dt><code>target</code></dt>
- <dd>获取属性的目标对象。</dd>
-</dl>
-
-<h3 id="返回值">返回值</h3>
-
-<p>目标对象自身和继承的可迭代属性的一个迭代器。</p>
-
-<h3 id="Exceptions">Exceptions</h3>
-
-<p> {{jsxref("TypeError")}}, 如果目标不是一个 {{jsxref("Object")}}.</p>
-
-<h2 id="描述">描述</h2>
-
-<p><code>Reflect.enumerate()</code>方法返回目标对象自身和继承的可迭代属性的一个迭代器。</p>
-
-<h2 id="案例">案例</h2>
-
-<h3 id="使用_Reflect.enumerate">使用 <code>Reflect.enumerate()</code></h3>
-
-<pre class="brush: js notranslate">var obj = { x: 1, y: 2 };
-
-for (var name of Reflect.enumerate(obj)) {
- console.log(name);
-}
-// logs "x" and "y"
-</pre>
-
-<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('ES2015', '#sec-reflect.enumerate', 'Reflect.enumerate')}}</td>
- <td>{{Spec2('ES2015')}}</td>
- <td>初始定义。ECMAScript 2016中已移除。</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>Firefox (Gecko)</th>
- <th>Internet Explorer</th>
- <th>Opera</th>
- <th>Safari</th>
- </tr>
- <tr>
- <td>Basic support</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</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>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- <td>{{CompatNo}}</td>
- </tr>
- </tbody>
-</table>
-</div>
-
-<h2 id="参照">参照</h2>
-
-<ul>
- <li>{{jsxref("Reflect")}}</li>
- <li><a href="/en-US/docs/Web/JavaScript/Reference/Statements/for...in">for...in</a></li>
-</ul>
diff --git a/files/zh-cn/archive/web/liveconnect/index.html b/files/zh-cn/archive/web/liveconnect/index.html
deleted file mode 100644
index 34b25bd823..0000000000
--- a/files/zh-cn/archive/web/liveconnect/index.html
+++ /dev/null
@@ -1,800 +0,0 @@
----
-title: LiveConnect概述
-slug: Archive/Web/LiveConnect
-tags:
- - Java
- - JavaScript
- - LiveConnect
- - 高级
-translation_of: Archive/Web/LiveConnect/LiveConnect_Overview
----
-<p>这一章描述了使用 <a href="/zh-CN/docs/LiveConnect" title="zh-CN/docs/LiveConnect">LiveConnect  </a>技术来使JavaScript和Java能够互相通信。本章假设你熟悉Java编程。</p>
-
-<h2 id="使用包装器(Working_with_Wrappers)">使用包装器(Working with Wrappers)</h2>
-
-<p>在JavaScript中,包装器(<em>wrapper</em>)是一个目标语言数据类型的对象,它包装了一个源语言的对象。当使用JavaScript编程的时候,你可以使用包装器(wrapper)对象来访问Java对象的方法和字段;调用包装器(wrapper)的方法或者访问它的属性都会作用在Java对象上。在Java端,JavaScript对象被包装在类netscape.javascript.JSObject的实例中,然后传递给Java。</p>
-
-<p>当Javascript对象被传递给Java,运行时引擎会创建一个JSObject类型的Java包装器(<em>wrapper</em>);当JSObject从Java传递到JavaScript, 运行时引擎将它解包成它原来的JavaScript对象类型。JSObject类提供了一个接口用来调用JavaScript的方法和检测JavaScript的属性。</p>
-
-<h2 id="JavaScript到Java通信">JavaScript到Java通信</h2>
-
-<p>当你引用一个Java包或者类,或者使用Java的对象和数组,你会使用某一个特别的LiveConnect对象。所有访问Java的JavaScript使用下面表格中总结的对象:</p>
-
-<table class="standard-table">
- <caption>Table 9.1 LiveConnect对象</caption>
- <thead>
- <tr>
- <th scope="col">对象</th>
- <th scope="col">描述</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>JavaArray</code></td>
- <td>包装了Java数组,从JavaScript代码中访问。</td>
- </tr>
- <tr>
- <td><code>JavaClass</code></td>
- <td>引用Java类。</td>
- </tr>
- <tr>
- <td><code>JavaObject</code></td>
- <td>包装了Java对象,从JavaScript代码中访问。</td>
- </tr>
- <tr>
- <td><code>JavaPackage</code></td>
- <td>引用Java包。</td>
- </tr>
- </tbody>
-</table>
-
-<p><strong>注意:</strong> 因为Java是强类型语言,而JavaScript是弱类型的语言,当你使用LiveConnect的时候,JavaScript运行时引擎会将参数值转换为其他语言中的合适数据类型。请参考 <a href="/zh-CN/docs/JavaScript/Guide/Values,_Variables,_and_Literals#Data_Type_Conversion" title="zh-CN/docs/JavaScript/Guide/Values, Variables, and Literals#Data Type Conversion">Data Type Conversion</a> 来获取完整信息。</p>
-
-<p>在某些情形下,LiveConnect对象的存在是透明的,因为你凭借一定的直觉来和Java交互。例如,你能够通过使用new操作符跟上Java构造器来像下面一样创建一个Java字符串(String)对象,并且将它赋值给JavaScript变量myString:</p>
-
-<pre class="brush: js">var myString = new java.lang.String("Hello world");
-</pre>
-
-<p>在上面的例子中,变量myString是一个JavaObject,因为它持有一个Java的String对象。作为<code>JavaObject</code>, <code>myString</code>可以获取java.lang.String及其父类java.lang.Object的公有实例方法。这些Java方法在JavaScript中作为JavaObject的方法使用,你可以像下面这样来使用它们:</p>
-
-<pre class="brush: js">myString.length(); // returns 11
-</pre>
-
-<p>静态成员可以通过JavaClass对象来调用。</p>
-
-<pre class="brush: js">alert(java.lang.Integer.MAX_VALUE); //alerts 2147483647
-</pre>
-
-<h3 id="包对象">包对象</h3>
-
-<p>如果一个Java类不是java, sun, 或者netscape包的一部分,你需要使用Packages对象来访问它。例如,假设Redwood公司使用一个叫redwood的java包来包含各种它实现的Java类。为了创建一个redwood中HelloWorld类的实例,你像下面这样访问类的构造器:</p>
-
-<pre class="brush: js">var red = new Packages.redwood.HelloWorld();
-</pre>
-
-<p>你也可以使用默认包中的类(就是说,类没有显式的命名包)。例如,如果HelloWorld类在CLASSPATH中,并且不在包中,你可以像下面这样使用它:</p>
-
-<pre class="brush: js">var red = new Packages.HelloWorld();
-</pre>
-
-<p>LiveConnect<code>中的java</code>, <code>sun</code>, 和<code>netscape</code>对象提供了常用Java包的快捷方式。例如,你可以像下面这样使用:</p>
-
-<pre class="brush: js">var myString = new java.lang.String("Hello world");
-</pre>
-
-<p>来替换下面长版本:</p>
-
-<pre class="brush: js">var myString = new Packages.java.lang.String("Hello world");
-</pre>
-
-<h3 id="使用Java数组">使用Java数组</h3>
-
-<p>当任何Java方法创建了一个数组,并且你在JavaScript中引用那个数组,你就会使用到JavaArray。例如,下面的代码创建了有十个int类型元素的JavaArray x对象:</p>
-
-<pre class="brush: js">var x = java.lang.reflect.Array.newInstance(java.lang.Integer, 10);
-</pre>
-
-<p>跟JavaScript的Array对象类似, JavaArray有一个length属性用来返回数组元素的长度。不像<code>Array.length</code>, <code>JavaArray.length是一个只读属性</code>, 因为Java数组的元素长度在创建的时候就固定了。</p>
-
-<h3 id="包和类的引用">包和类的引用</h3>
-
-<p>Simple references to Java packages and classes from JavaScript create the <code>JavaPackage</code> and <code>JavaClass</code> objects. In the earlier example about the Redwood corporation, for example, the reference Packages.redwood is a JavaPackage object. Similarly, a reference such as <code>java.lang.String</code> is a <code>JavaClass</code> object.</p>
-
-<p>Most of the time, you don't have to worry about the <code>JavaPackage</code> and <code>JavaClass</code> objects—you just work with Java packages and classes, and LiveConnect creates these objects transparently. There are cases where LiveConnect will fail to load a class, and you will need to manually load it like this:</p>
-
-<pre class="brush: js">var Widgetry = java.lang.Thread.currentThread().getContextClassLoader().loadClass("org.mywidgets.Widgetry");
-</pre>
-
-<p>In JavaScript 1.3 and earlier, <code>JavaClass</code> objects are not automatically converted to instances of <code>java.lang.Class</code> when you pass them as parameters to Java methods—you must create a wrapper around an instance of <code>java.lang.Class</code>. In the following example, the <code>forName</code> method creates a wrapper object <code>theClass</code>, which is then passed to the <code>newInstance</code> method to create an array.</p>
-
-<pre class="brush: js">// JavaScript 1.3
-var theClass = java.lang.Class.forName("java.lang.String");
-var theArray = java.lang.reflect.Array.newInstance(theClass, 5);
-</pre>
-
-<p>In JavaScript 1.4 and later, you can pass a <code>JavaClass</code> object directly to a method, as shown in the following example:</p>
-
-<pre class="brush: js">// JavaScript 1.4
-var theArray = java.lang.reflect.Array.newInstance(java.lang.String, 5);
-</pre>
-
-<h3 id="Arguments_of_Type_char">Arguments of Type char</h3>
-
-<p>In JavaScript 1.4 and later, you can pass a one-character string to a Java method which requires an argument of type <code>char</code>. For example, you can pass the string "H" to the <code>Character</code> constructor as follows:</p>
-
-<pre class="brush: js">var c = new java.lang.Character("H");
-</pre>
-
-<p>In JavaScript 1.3 and earlier, you must pass such methods an integer which corresponds to the Unicode value of the character. For example, the following code also assigns the value "H" to the variable <code>c</code>:</p>
-
-<pre class="brush: js">var c = new java.lang.Character(72);
-</pre>
-
-<h3 id="Handling_Java_Exceptions_in_JavaScript">Handling Java Exceptions in JavaScript</h3>
-
-<p>When Java code fails at run time, it throws an exception. If your JavaScript code accesses a Java data member or method and fails, the Java exception is passed on to JavaScript for you to handle. Beginning with JavaScript 1.4, you can catch this exception in a <code>try...catch</code> statement. (Although this functionality (along with some others) had been broken in Gecko 1.9 (see {{ bug("391642") }}) as the Mozilla-specific LiveConnect code had not been maintained inside Mozilla, with Java 6 update 11 and 12 building support for reliance on Mozilla's implementation of the generic (and cross-browser) <a href="/zh-CN/docs/Plugins" title="zh-CN/docs/Plugins">NPAPI</a> plugin code, this has again been fixed.)</p>
-
-<p>For example, suppose you are using the Java <code>forName</code> method to assign the name of a Java class to a variable called <code>theClass</code>. The <code>forName</code> method throws an exception if the value you pass it does not evaluate to the name of a Java class. Place the <code>forName</code> assignment statement in a <code>try</code> block to handle the exception, as follows:</p>
-
-<pre class="brush: js">function getClass(javaClassName) {
- try {
- var theClass = java.lang.Class.forName(javaClassName);
- } catch (e) {
- return ("The Java exception is " + e);
- }
- return theClass;
-}
-</pre>
-
-<p>In this example, if <code>javaClassName</code> evaluates to a legal class name, such as "java.lang.String", the assignment succeeds. If <code>javaClassName</code> evaluates to an invalid class name, such as "String", the <code>getClass</code> function catches the exception and returns something similar to the following:</p>
-
-<pre>The Java exception is java.lang.ClassNotFoundException: String
-</pre>
-
-<p>For specialized handling based on the exception type, use the <code>instanceof</code> operator:</p>
-
-<pre class="brush: js">try {
- // ...
-} catch (e) {
- if (e instanceof java.io.FileNotFound) {
- // handling for FileNotFound
- } else {
- throw e;
- }
-}
-</pre>
-
-<p>See <a href="/zh-CN/docs/JavaScript/Guide/Statements#Exception_Handling_Statements" title="zh-CN/docs/JavaScript/Guide/Statements#Exception Handling Statements">Exception Handling Statements</a> for more information about JavaScript exceptions.</p>
-
-<h2 id="Java_to_JavaScript_Communication">Java to JavaScript Communication</h2>
-
-<p>If you want to use JavaScript objects in Java, you must import the <code>netscape.javascript</code> package into your Java file. This package defines the following classes:</p>
-
-<ul>
- <li><code><a href="/zh-CN/docs/JavaScript/Reference/LiveConnect/JSObject" title="zh-CN/docs/JavaScript/Reference/LiveConnect/JSObject">netscape.javascript.JSObject</a></code> allows Java code to access JavaScript methods and properties.</li>
- <li><code><a href="/zh-CN/docs/JavaScript/Reference/LiveConnect/JSException" title="zh-CN/docs/JavaScript/Reference/LiveConnect/JSException">netscape.javascript.JSException</a></code> allows Java code to handle JavaScript errors.</li>
-</ul>
-
-<p>See the <a href="/zh-CN/docs/JavaScript/Reference" title="zh-CN/docs/JavaScript/Reference">JavaScript Reference</a> for more information about these classes.</p>
-
-<h3 id="Locating_the_LiveConnect_classes" name="Locating_the_LiveConnect_classes">Locating the LiveConnect classes</h3>
-
-<p>In older versions of the Netscape browser, these classes were distributed along with the browser. Starting with JavaScript 1.2, these classes are delivered in a .jar file; in previous versions of JavaScript, these classes are delivered in a .zip file. For example, with Netscape Navigator 4 for Windows NT, the classes are delivered in the <code>java40.jar</code> file in the <code>Program\Java\Classes</code> directory beneath the Navigator directory.</p>
-
-<p>More recently, the classes have been distributed with Sun's Java Runtime; initially in the file "jaws.jar" in the "jre/lib" directory of the runtime distribution (for JRE 1.3), then in "plugin.jar" in the same location (JRE 1.4 and up).</p>
-
-<h3 id="Using_the_LiveConnect_classes_with_the_JDK" name="Using_the_LiveConnect_classes_with_the_JDK">Using the LiveConnect classes with the JDK</h3>
-
-<p>To access the LiveConnect classes, place the .jar or .zip file in the <code>CLASSPATH</code> of the JDK compiler in either of the following ways:</p>
-
-<ul>
- <li>Create a <code>CLASSPATH</code> environment variable to specify the path and name of .jar or .zip file.</li>
- <li>Specify the location of .jar or .zip file when you compile by using the <code>-classpath</code> command line parameter.</li>
-</ul>
-
-<p>You can specify an environment variable in Windows NT by double-clicking the System icon in the Control Panel and creating a user environment variable called <code>CLASSPATH</code> with a value similar to the following:</p>
-
-<pre class="eval">C:\Program Files\Java\jre1.4.1\lib\plugin.jar
-</pre>
-
-<p>See the Sun JDK documentation for more information about <code>CLASSPATH</code>.</p>
-
-<p><strong>Note:</strong> Because Java is a strongly typed language and JavaScript is weakly typed, the JavaScript runtime engine converts argument values into the appropriate data types for the other language when you use LiveConnect. See <a href="#Data_Type_Conversions">Data Type Conversions</a> for complete information.</p>
-
-<h3 id="Using_the_LiveConnect_Classes">Using the LiveConnect Classes</h3>
-
-<p>All JavaScript objects appear within Java code as instances of <code>netscape.javascript.JSObject</code>. When you call a method in your Java code, you can pass it a JavaScript object as one of its argument. To do so, you must define the corresponding formal parameter of the method to be of type <code>JSObject</code>.</p>
-
-<p>Also, any time you use JavaScript objects in your Java code, you should put the call to the JavaScript object inside a <code>try...catch</code> statement which handles exceptions of type <code>netscape.javascript.JSException</code>. This allows your Java code to handle errors in JavaScript code execution which appear in Java as exceptions of type <code>JSException</code>.</p>
-
-<h4 id="Accessing_JavaScript_with_JSObject" name="Accessing_JavaScript_with_JSObject">Accessing JavaScript with JSObject</h4>
-
-<p>For example, suppose you are working with the Java class called <code>JavaDog</code>. As shown in the following code, the <code>JavaDog</code> constructor takes the JavaScript object <code>jsDog</code>, which is defined as type <code>JSObject</code>, as an argument:</p>
-
-<pre class="brush: java">import netscape.javascript.*;
-
-public class JavaDog{
- public String dogBreed;
- public String dogColor;
- public String dogSex;
-
- // define the class constructor
- public JavaDog(JSObject jsDog){
- // use try...catch to handle JSExceptions here
- this.dogBreed = (String)jsDog.getMember("breed");
- this.dogColor = (String)jsDog.getMember("color");
- this.dogSex = (String)jsDog.getMember("sex");
- }
-}
-</pre>
-
-<p>Notice that the <code>getMember</code> method of <code>JSObject</code> is used to access the properties of the JavaScript object. The previous example uses <code>getMember</code> to assign the value of the JavaScript property <code>jsDog.breed</code> to the Java data member <code>JavaDog.dogBreed</code>.</p>
-
-<p><strong>Note:</strong> A more realistic example would place the call to <code>getMember</code> inside a <code>try...catch</code> statement to handle errors of type <code>JSException</code>. See Handling JavaScript Exceptions in Java for more information.</p>
-
-<p>To get a better sense of how <code>getMember</code> works, look at the definition of the custom JavaScript object <code>Dog</code>:</p>
-
-<pre class="brush: js">function Dog(breed,color,sex){
- this.breed = breed;
- this.color = color;
- this.sex = sex;
-}
-</pre>
-
-<p>You can create a JavaScript instance of <code>Dog</code> called <code>gabby</code> as follows:</p>
-
-<pre class="brush: js">var gabby = new Dog("lab", "chocolate", "female");
-</pre>
-
-<p>If you evaluate <code>gabby.color</code>, you can see that it has the value "chocolate". Now suppose you create an instance of <code>JavaDog</code> in your JavaScript code by passing the <code>gabby</code> object to the constructor as follows:</p>
-
-<pre class="brush: js">var javaDog = new Packages.JavaDog(gabby);
-</pre>
-
-<p>If you evaluate <code>javaDog.dogColor</code>, you can see that it also has the value "chocolate", because the <code>getMember</code> method in the Java constructor assigns <code>dogColor</code> the value of <code>gabby.color</code>.</p>
-
-<h4 id="Handling_JavaScript_Exceptions_in_Java" name="Handling_JavaScript_Exceptions_in_Java">Handling JavaScript Exceptions in Java</h4>
-
-<p>When JavaScript code called from Java fails at run time, it throws an exception. If you are calling the JavaScript code from Java, you can catch this exception in a <code>try...catch</code> statement. The JavaScript exception is available to your Java code as an instance of <code>netscape.javascript.JSException</code>.</p>
-
-<p><code>JSException</code> is a Java wrapper around any exception type thrown by JavaScript, similar to the way that instances of <code>JSObject</code> are wrappers for JavaScript objects. Use <code>JSException</code> when you are evaluating JavaScript code in Java.</p>
-
-<p>When you are evaluating JavaScript code in Java, the following situations can cause run-time errors:</p>
-
-<ul>
- <li>The JavaScript code is not evaluated, either due to a JavaScript compilation error or to some other error that occurred at run time. The JavaScript interpreter generates an error message that is converted into an instance of <code>JSException</code>.</li>
- <li>Java successfully evaluates the JavaScript code, but the JavaScript code executes an unhandled <code>throw</code> statement. JavaScript throws an exception that is wrapped as an instance of <code>JSException</code>. Use the <code>getWrappedException</code> method of <code>JSException</code> to unwrap this exception in Java.</li>
-</ul>
-
-<p>For example, suppose the Java object <code>eTest</code> evaluates the string <code>jsCode</code> that you pass to it. You can respond to either type of run-time error the evaluation causes by implementing an exception handler such as the following:</p>
-
-<pre class="brush: java">import netscape.javascript.JSObject;
-import netscape.javascript.JSException;
-
-public class eTest {
- public static Object doit(JSObject obj, String jsCode) {
- try {
- obj.eval(jsCode);
- } catch (JSException e) {
- if (e.getWrappedException() == null)
- return e;
- return e.getWrappedException();
- }
- return null;
- }
-}
-</pre>
-
-<p>In this example, the code in the <code>try</code> block attempts to evaluate the string <code>jsCode</code> that you pass to it. Let's say you pass the string "<code>myFunction()</code>" as the value of <code>jsCode</code>. If <code>myFunction</code> is not defined as a JavaScript function, the JavaScript interpreter cannot evaluate <code>jsCode</code>. The interpreter generates an error message, the Java handler catches the message, and the <code>doit</code> method returns an instance of <code>netscape.javascript.JSException</code>.</p>
-
-<p>However, suppose <code>myFunction</code> is defined in JavaScript as follows:</p>
-
-<pre class="brush: js">function myFunction() {
- try {
- if (theCondition == true) {
- return "Everything's ok";
- } else {
- throw "JavaScript error occurred";
- }
- } catch (e) {
- if (canHandle == true) {
- handleIt();
- } else {
- throw e;
- }
- }
-}
-</pre>
-
-<p>If <code>theCondition</code> is false, the function throws an exception. The exception is caught in the JavaScript code, and if <code>canHandle</code> is true, JavaScript handles it. If <code>canHandle</code> is false, the exception is rethrown, the Java handler catches it, and the <code>doit</code> method returns a Java string:</p>
-
-<pre>JavaScript error occurred
-</pre>
-
-<p>See <a href="/zh-CN/docs/JavaScript/Guide/Statements#Exception_Handling_Statements" title="zh-CN/docs/JavaScript/Guide/Statements#Exception Handling Statements">Exception Handling Statements</a> for complete information about JavaScript exceptions.</p>
-
-<h4 id="Backward_Compatibility" name="Backward_Compatibility">Backward Compatibility</h4>
-
-<p>In JavaScript 1.3 and earlier versions, the <code>JSException</code> class had three public constructors which optionally took a string argument, specifying the detail message or other information for the exception. The <code>getWrappedException</code> method was not available.</p>
-
-<p>Use a <code>try...catch</code> statement such as the following to handle LiveConnect exceptions in JavaScript 1.3 and earlier versions:</p>
-
-<pre class="brush: js">try {
- global.eval("foo.bar = 999;");
-} catch (Exception e) {
- if (e instanceof JSException) {
- jsCodeFailed();
- } else {
- otherCodeFailed();
- }
-}
-</pre>
-
-<p>In this example, the <code>eval</code> statement fails if <code>foo</code> is not defined. The <code>catch</code> block executes the <code>jsCodeFailed</code> method if the <code>eval</code> statement in the <code>try</code> block throws a <code>JSException</code>; the <code>otherCodeFailed</code> method executes if the <code>try</code> block throws any other error.</p>
-
-<h2 id="Data_Type_Conversions">Data Type Conversions</h2>
-
-<p>Because Java is a strongly typed language and JavaScript is weakly typed, the JavaScript runtime engine converts argument values into the appropriate data types for the other language when you use LiveConnect. These conversions are described in the following sections:</p>
-
-<ul>
- <li><a href="#JavaScript_to_Java_Conversions">JavaScript to Java Conversions</a></li>
- <li><a href="#Java_to_JavaScript_Conversions">Java to JavaScript Conversions</a></li>
-</ul>
-
-<h3 id="JavaScript_to_Java_Conversions">JavaScript to Java Conversions</h3>
-
-<p>When you call a Java method and pass it parameters from JavaScript, the data types of the parameters you pass in are converted according to the rules described in the following sections:</p>
-
-<ul>
- <li><a href="#Number_Values">Number Values</a></li>
- <li><a href="#Boolean_Values">Boolean Values</a></li>
- <li><a href="#String_Values">String Values</a></li>
- <li><a href="#Undefined_Values">Undefined Values</a></li>
- <li><a href="#Null_Values">Null Values</a></li>
- <li><a href="#JavaArray_and_JavaObject_objects">JavaArray and JavaObject objects</a></li>
- <li><a href="#JavaClass_objects">JavaClass objects</a></li>
- <li><a href="#Other_JavaScript_objects">Other JavaScript objects</a></li>
-</ul>
-
-<p>The return values of methods of <code>netscape.javascript.JSObject</code> are always converted to instances of <code>java.lang.Object</code>. The rules for converting these return values are also described in these sections.</p>
-
-<p>For example, if <code>JSObject.eval</code> returns a JavaScript number, you can find the rules for converting this number to an instance of <code>java.lang.Object</code> in <a href="#Number_Values">Number Values</a>.</p>
-
-<h4 id="Number_Values" name="Number_Values">Number Values</h4>
-
-<p>When you pass JavaScript number types as parameters to Java methods, Java converts the values according to the rules described in the following table:</p>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Java parameter type</th>
- <th scope="col">Conversion rules</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>double</td>
- <td>
- <ul>
- <li>The exact value is transferred to Java without rounding and without a loss of magnitude or sign.</li>
- <li><code>NaN</code> is converted to NaN.</li>
- </ul>
- </td>
- </tr>
- <tr>
- <td>java.lang.Double<br>
- java.lang.Object</td>
- <td>A new instance of <code>java.lang.Double</code> is created, and the exact value is transferred to Java without rounding and without a loss of magnitude or sign.</td>
- </tr>
- <tr>
- <td>float</td>
- <td>
- <ul>
- <li>Values are rounded to float precision.</li>
- <li>Values which are too large or small to be represented are rounded to +infinity or -infinity.</li>
- <li><code>NaN</code> is converted to <code>NaN</code>.</li>
- </ul>
- </td>
- </tr>
- <tr>
- <td>byte
- <p>char<br>
- int<br>
- long</p>
- short</td>
- <td>
- <ul>
- <li>Values are rounded using round-to-negative-infinity mode.</li>
- <li>Values which are too large or small to be represented result in a run-time error.</li>
- <li><code>NaN</code> can not be converted and results in a run-time error.</li>
- </ul>
- </td>
- </tr>
- <tr>
- <td><code>java.lang.String</code></td>
- <td>Values are converted to strings. For example:
- <ul>
- <li>237 becomes "237"</li>
- </ul>
- </td>
- </tr>
- <tr>
- <td>boolean</td>
- <td>
- <ul>
- <li>0 and <code>NaN</code> values are converted to false.</li>
- <li>Other values are converted to true.</li>
- </ul>
- </td>
- </tr>
- </tbody>
-</table>
-
-<p>When a JavaScript number is passed as a parameter to a Java method which expects an instance of <code>java.lang.String</code>, the number is converted to a string. Use the <code>equals()</code> method to compare the result of this conversion with other string values.</p>
-
-<h4 id="Boolean_Values" name="Boolean_Values">Boolean Values</h4>
-
-<p>When you pass JavaScript Boolean types as parameters to Java methods, Java converts the values according to the rules described in the following table:</p>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Java parameter type</th>
- <th scope="col">Conversion rules</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>boolean</td>
- <td>All values are converted directly to the Java equivalents.</td>
- </tr>
- <tr>
- <td><code>java.lang.Boolean</code><br>
- <code>java.lang.Object</code></td>
- <td>A new instance of <code>java.lang.Boolean</code> is created. Each parameter creates a new instance, not one instance with the same primitive value.</td>
- </tr>
- <tr>
- <td><code>java.lang.String</code></td>
- <td>Values are converted to strings. For example:
- <ul>
- <li>true becomes "true"</li>
- <li>false becomes "false"</li>
- </ul>
- </td>
- </tr>
- <tr>
- <td>byte
- <p>char<br>
- double<br>
- float<br>
- int<br>
- long</p>
- short</td>
- <td>
- <ul>
- <li>true becomes 1</li>
- <li>false becomes 0</li>
- </ul>
- </td>
- </tr>
- </tbody>
-</table>
-
-<p>When a JavaScript Boolean is passed as a parameter to a Java method which expects an instance of <code>java.lang.String</code>, the Boolean is converted to a string. Use the == operator to compare the result of this conversion with other string values.</p>
-
-<h4 id="String_Values" name="String_Values">String Values</h4>
-
-<p>When you pass JavaScript string types as parameters to Java methods, Java converts the values according to the rules described in the following table:</p>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Java parameter type</th>
- <th scope="col">Conversion rules</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>java.lang.String</code><br>
- <code>java.lang.Object</code></td>
- <td>JavaScript 1.4:
- <ul>
- <li>A JavaScript string is converted to an instance of <code>java.lang.String</code> with a Unicode value.</li>
- </ul>
-
- <p>JavaScript 1.3 and earlier:</p>
-
- <ul>
- <li>A JavaScript string is converted to an instance of <code>java.lang.String</code> with an ASCII value.</li>
- </ul>
- </td>
- </tr>
- <tr>
- <td>byte
- <p>double<br>
- float<br>
- int<br>
- long</p>
- short</td>
- <td>All values are converted to numbers as described in ECMA-262. The JavaScript string value is converted to a number according to the rules described in ECMA-262.</td>
- </tr>
- <tr>
- <td>char</td>
- <td>JavaScript 1.4:
- <ul>
- <li>One-character strings are converted to Unicode characters.</li>
- <li>All other values are converted to numbers.</li>
- </ul>
-
- <p>JavaScript 1.3 and earlier:</p>
-
- <ul>
- <li>All values are converted to numbers.</li>
- </ul>
- </td>
- </tr>
- <tr>
- <td>boolean</td>
- <td>
- <ul>
- <li>The empty string becomes false.</li>
- <li>All other values become true.</li>
- </ul>
- </td>
- </tr>
- </tbody>
-</table>
-
-<h4 id="Undefined_Values" name="Undefined_Values">Undefined Values</h4>
-
-<p>When you pass undefined JavaScript values as parameters to Java methods, Java converts the values according to the rules described in the following table:</p>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Java parameter type</th>
- <th scope="col">Conversion rules</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>java.lang.String</code><br>
- <code>java.lang.Object</code></td>
- <td>The value is converted to an instance of java.lang.String whose value is the string "undefined".</td>
- </tr>
- <tr>
- <td>boolean</td>
- <td>The value becomes false.</td>
- </tr>
- <tr>
- <td>double<br>
- float</td>
- <td>The value becomes <code>NaN</code>.</td>
- </tr>
- <tr>
- <td>byte
- <p>char<br>
- int<br>
- long</p>
- short</td>
- <td>The value becomes 0.</td>
- </tr>
- </tbody>
-</table>
-
-<p>The undefined value conversion is possible in JavaScript 1.3 and later versions only. Earlier versions of JavaScript do not support undefined values.</p>
-
-<p>When a JavaScript undefined value is passed as a parameter to a Java method which expects an instance of <code>java.lang.String</code>, the undefined value is converted to a string. Use the == operator to compare the result of this conversion with other string values.</p>
-
-<h4 id="Null_Values" name="Null_Values">Null Values</h4>
-
-<p>When you pass null JavaScript values as parameters to Java methods, Java converts the values according to the rules described in the following table:</p>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Java parameter type</th>
- <th scope="col">Conversion rules</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>Any class<br>
- Any interface type</td>
- <td>The value becomes null.</td>
- </tr>
- <tr>
- <td>byte
- <p>char<br>
- double<br>
- float<br>
- int<br>
- long</p>
- short</td>
- <td>The value becomes 0.</td>
- </tr>
- <tr>
- <td>boolean</td>
- <td>The value becomes false.</td>
- </tr>
- </tbody>
-</table>
-
-<h4 id="JavaArray_and_JavaObject_objects" name="JavaArray_and_JavaObject_objects">JavaArray and JavaObject objects</h4>
-
-<p>In most situations, when you pass a JavaScript <code>JavaArray</code> or <code>JavaObject</code> as a parameter to a Java method, Java simply unwraps the object; in a few situations, the object is coerced into another data type according to the rules described in the following table:</p>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Java parameter type</th>
- <th scope="col">Conversion rules</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>Any interface or class that is assignment-compatible with the unwrapped object.</td>
- <td>The object is unwrapped.</td>
- </tr>
- <tr>
- <td><code>java.lang.String</code></td>
- <td>The object is unwrapped, the <code>toString</code> method of the unwrapped Java object is called, and the result is returned as a new instance of <code>java.lang.String</code>.</td>
- </tr>
- <tr>
- <td>byte
- <p>char<br>
- double<br>
- float<br>
- int<br>
- long</p>
- short</td>
- <td>The object is unwrapped, and either of the following situations occur:
- <ul>
- <li>If the unwrapped Java object has a <code>doubleValue</code> method, the <code>JavaArray</code> or <code>JavaObject</code> is converted to the value returned by this method.</li>
- <li>If the unwrapped Java object does not have a <code>doubleValue</code> method, an error occurs.</li>
- </ul>
- </td>
- </tr>
- <tr>
- <td>boolean</td>
- <td>In JavaScript 1.3 and later versions, the object is unwrapped and either of the following situations occur:
- <ul>
- <li>If the object is null, it is converted to false.</li>
- <li>If the object has any other value, it is converted to true.</li>
- </ul>
-
- <p>In JavaScript 1.2 and earlier versions, the object is unwrapped and either of the following situations occur:</p>
-
- <ul>
- <li>If the unwrapped object has a booleanValue method, the source object is converted to the return value.</li>
- <li>If the object does not have a booleanValue method, the conversion fails.</li>
- </ul>
- </td>
- </tr>
- </tbody>
-</table>
-
-<p>An interface or class is assignment-compatible with an unwrapped object if the unwrapped object is an instance of the Java parameter type. That is, the following statement must return true:</p>
-
-<pre class="brush: js">unwrappedObject instanceof parameterType;
-</pre>
-
-<h4 id="JavaClass_objects" name="JavaClass_objects">JavaClass objects</h4>
-
-<p>When you pass a JavaScript <code>JavaClass</code> object as a parameter to a Java method, Java converts the object according to the rules described in the following table:</p>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Java parameter type</th>
- <th scope="col">Conversion rules</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>java.lang.Class</code></td>
- <td>The object is unwrapped.</td>
- </tr>
- <tr>
- <td><code>netscape.javascript.JSObject</code><br>
- <code>java.lang.Object</code></td>
- <td>The <code>JavaClass</code> object is wrapped in a new instance of <code>netscape.javascript.JSObject</code>.</td>
- </tr>
- <tr>
- <td><code>java.lang.String</code></td>
- <td>The object is unwrapped, the <code>toString</code> method of the unwrapped Java object is called, and the result is returned as a new instance of <code>java.lang.String</code>.</td>
- </tr>
- <tr>
- <td>boolean</td>
- <td>In JavaScript 1.3 and later versions, the object is unwrapped and either of the following situations occur:
- <ul>
- <li>If the object is null, it is converted to false.</li>
- <li>If the object has any other value, it is converted to true.</li>
- </ul>
-
- <p>In JavaScript 1.2 and earlier versions, the object is unwrapped and either of the following situations occur:</p>
-
- <ul>
- <li>If the unwrapped object has a booleanValue method, the source object is converted to the return value.</li>
- <li>If the object does not have a booleanValue method, the conversion fails.</li>
- </ul>
- </td>
- </tr>
- </tbody>
-</table>
-
-<h4 id="Other_JavaScript_objects" name="Other_JavaScript_objects">Other JavaScript objects</h4>
-
-<p>When you pass any other JavaScript object as a parameter to a Java method, Java converts the object according to the rules described in the following table:</p>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Java parameter type</th>
- <th scope="col">Conversion rules</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td><code>netscape.javascript.JSObject</code><br>
- <code>java.lang.Object</code></td>
- <td>The object is wrapped in a new instance of <code>netscape.javascript.JSObject</code>.</td>
- </tr>
- <tr>
- <td><code>java.lang.String</code></td>
- <td>The object is unwrapped, the <code>toString</code> method of the unwrapped object is called, and the result is returned as a new instance of <code>java.lang.String</code>.</td>
- </tr>
- <tr>
- <td>byte
- <p>char<br>
- double<br>
- float<br>
- int<br>
- long</p>
- short</td>
- <td>The object is converted to a value using the logic of the <code>ToPrimitive</code> operator described in ECMA-262. The <em>PreferredType</em> hint used with this operator is Number.</td>
- </tr>
- <tr>
- <td>boolean</td>
- <td>In JavaScript 1.3 and later versions, the object is unwrapped and either of the following situations occur:
- <ul>
- <li>If the object is null, it is converted to false.</li>
- <li>If the object has any other value, it is converted to true.</li>
- </ul>
-
- <p>In JavaScript 1.2 and earlier versions, the object is unwrapped and either of the following situations occur:</p>
-
- <ul>
- <li>If the unwrapped object has a booleanValue method, the source object is converted to the return value.</li>
- <li>If the object does not have a booleanValue method, the conversion fails.</li>
- </ul>
- </td>
- </tr>
- </tbody>
-</table>
-
-<h3 id="Java_to_JavaScript_Conversions">Java to JavaScript Conversions</h3>
-
-<p>Values passed from Java to JavaScript are converted as follows:</p>
-
-<ul>
- <li>Java byte, char, short, int, long, float, and double are converted to JavaScript numbers.</li>
- <li>A Java boolean is converted to a JavaScript boolean.</li>
- <li>An object of class <code>netscape.javascript.JSObject</code> is converted to the original JavaScript object.</li>
- <li>Java arrays are converted to a JavaScript pseudo-Array object; this object behaves just like a JavaScript <code>Array</code> object: you can access it with the syntax <code>arrayName[index]</code> (where <code>index</code> is an integer), and determine its length with <code>arrayName.length</code>.</li>
- <li>A Java object of any other class is converted to a JavaScript wrapper, which can be used to access methods and fields of the Java object:
- <ul>
- <li>Converting this wrapper to a string calls the <code>toString</code> method on the original object.</li>
- <li>Converting to a number calls the <code>doubleValue</code> method, if possible, and fails otherwise.</li>
- <li>Converting to a boolean in JavaScript 1.3 and later versions returns false if the object is null, and true otherwise.</li>
- <li>Converting to a boolean in JavaScript 1.2 and earlier versions calls the <code>booleanValue</code> method, if possible, and fails otherwise.</li>
- </ul>
- </li>
-</ul>
-
-<p>Note that instances of java.lang.Double and java.lang.Integer are converted to JavaScript objects, not to JavaScript numbers. Similarly, instances of java.lang.String are also converted to JavaScript objects, not to JavaScript strings.</p>
-
-<p>Java <code>String</code> objects also correspond to JavaScript wrappers. If you call a JavaScript method that requires a JavaScript string and pass it this wrapper, you'll get an error. Instead, convert the wrapper to a JavaScript string by appending the empty string to it, as shown here:</p>
-
-<pre class="brush: js">var JavaString = JavaObj.methodThatReturnsAString();
-var JavaScriptString = JavaString + "";</pre>