mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-12-18 17:04:28 +08:00
语法高亮,滚动条美化,设置页面调整
This commit is contained in:
@@ -4,15 +4,15 @@
|
||||
<div><iframe class="interactive interactive-js" frameborder="0" height="250" src="https://interactive-examples.mdn.mozilla.net/pages/js/date-toisostring.html" width="100%"></iframe></div>
|
||||
<p class="hidden">The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone <a class="external" href="https://github.com/mdn/interactive-examples" rel="noopener">https://github.com/mdn/interactive-examples</a> and send us a pull request.</p>
|
||||
<h2 id="Syntax" name="Syntax">语法</h2>
|
||||
<pre class="syntaxbox"><var>dateObj</var>.toISOString()</pre>
|
||||
<pre><code class="language-javascript"><var>dateObj</var>.toISOString()</code></pre>
|
||||
<h2 id="例子">例子</h2>
|
||||
<pre class="brush: js">var today = new Date("05 October 2011 14:48 UTC");
|
||||
<pre><code class="language-javascript">var today = new Date("05 October 2011 14:48 UTC");
|
||||
alert(today.toISOString()); // 返回2011-10-05T14:48:00.000Z
|
||||
</pre>
|
||||
</code></pre>
|
||||
<p>上例使用了非标准字符串的解析,该字符串在某些旧的浏览器(如IE)中可能无法被正确解析。</p>
|
||||
<h2 id="Description" name="Description">Polyfill</h2>
|
||||
<p>该方法在ECMA-262第5版中被标准化。对于那些不支持此方法的JS引擎可以通过加上下面的代码实现:</p>
|
||||
<pre class="brush:js">if ( !Date.prototype.toISOString ) {
|
||||
<pre><code class="language-js">if ( !Date.prototype.toISOString ) {
|
||||
( function() {
|
||||
|
||||
function pad(number) {
|
||||
@@ -34,7 +34,7 @@ alert(today.toISOString()); // 返回2011-10-05T14:48:00.000Z
|
||||
};
|
||||
|
||||
}() );
|
||||
}</pre>
|
||||
}</code></pre>
|
||||
<h2 id="规范">规范</h2>
|
||||
<table class="standard-table">
|
||||
<tbody>
|
||||
|
||||
Reference in New Issue
Block a user