mozilla

Revision 80628 of DownloadLastDir.jsm

  • Revision slug: JavaScript_code_modules/DownloadLastDir.jsm
  • Revision title: DownloadLastDir.jsm
  • Revision id: 80628
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment new page; see bug 508526; page created, 198 words added

Revision Content

{{ gecko_minversion_header("2.0") }}

The DownloadLastDir.jsm JavaScript code module lets you retrieve the path of the last directory into which a download occurred.

To use this, you first need to import the code module into your JavaScript scope:

Components.utils.import("resource://gre/modules/DownloadLastDir.jsm");

Once you've imported the module, you can then use the gDownloadLastDir object it exports. This is a string indicating the path into which the last download occurred.

Using the gDownloadLastDir object

To determine the path into which the last download occurred, simply read the gDownloadLastDir global:

var path = gDownloadLastDir;

Private browsing mode

When browsing normally, the browser uses the browser.download.lastDir preference to store the last download directory path. However, when private browsing mode is enabled, the last download directory path is instead maintained in memory, and the preference is not changed.

When the user exits private browsing mode, the last download directory value is reverted to the preference's value.

When history is cleared

When the user's browsing history is cleared, the value of the last download directory path is restored to the platform's default download directory path.

See also

Revision Source

<p>{{ gecko_minversion_header("2.0") }}</p>
<p>The <code>DownloadLastDir.jsm</code> JavaScript code module lets you retrieve the path of the last directory into which a download occurred.</p>
<p>To use this, you first need to import the code module into your JavaScript scope:</p>
<pre>Components.utils.import("resource://gre/modules/DownloadLastDir.jsm");
</pre>
<p>Once you've imported the module, you can then use the <code>gDownloadLastDir</code> object it exports. This is a string indicating the path into which the last download occurred.</p>
<h2>Using the gDownloadLastDir object</h2>
<p>To determine the path into which the last download occurred, simply read the <code>gDownloadLastDir</code> global:</p>
<pre class="deki-transform">var path = gDownloadLastDir;
</pre>
<h2>Private browsing mode</h2>
<p>When browsing normally, the browser uses the <code>browser.download.lastDir</code> preference to store the last download directory path. However, when private browsing mode is enabled, the last download directory path is instead maintained in memory, and the preference is not changed.</p>
<p>When the user exits private browsing mode, the last download directory value is reverted to the preference's value.</p>
<h2>When history is cleared</h2>
<p>When the user's browsing history is cleared, the value of the last download directory path is restored to the platform's default download directory path.</p>
<h2>See also</h2>
<ul> <li><a class="internal" href="/en/JavaScript/Code_modules/Using" title="en/JavaScript code modules/Using JavaScript code modules">Using JavaScript code modules</a></li> <li><a class="internal" href="/en/JavaScript/Code_modules" title="en/JavaScript code modules">JavaScript code modules</a></li>
</ul>
Revert to this revision