Revision 108666 of openLocationLastURL.jsm

  • Revision slug: JavaScript_code_modules/openLocationLastURL.jsm
  • Revision title: openLocationLastURL.jsm
  • Revision id: 108666
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment 30 words removed

Revision Content

{{ gecko_minversion_header("1.9.1.4") }}

The openLocationLastURL.jsm JavaScript code module lets you set and retrieve the URL most recently opened using the "Open Location" option in the File menu.

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

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

Once you've imported the module, you can then use the gOpenLocationLastURL object it exports. This object lets you fetch and change the URL that is placed in the "Open Location" dialog box when it opens.

Note: This module automatically handles private browsing mode for you. The value preserved across accesses is not preserved when the user exits private browsing mode.

Using the gOpenLocationLastURL object

To get or set the value of the Open Location edit box, simply read the value of, or set the value of, the gOpenLocationLastURL.value field:

var url = gOpenLocationLastURL.value;

gOpenLocationLastURL.value = "http://www.mozilla.org/"; 

To reset the value of the edit box to the default (which is an empty string), you can call the reset() method:

Method overview

reset()

Methods

reset

The reset() method resets the saved URL to the default, which is an empty string.

reset();
Parameters

None.

See also

Revision Source

<p>{{ gecko_minversion_header("1.9.1.4") }}</p>
<p>The <span style="font-family: monospace;">openLocationLastURL</span><code>.jsm</code> JavaScript code module lets you set and retrieve the URL most recently opened using the "Open Location" option in the File menu.</p>
<p>To use this, you first need to import the code module into your JavaScript scope:</p>
<pre class="eval"><span class="nowiki">Components.utils.import("</span><a class=" external" href="resource://gre/modules/XPCOMUtils.jsm" rel="external nofollow" target="_blank" title="resource://gre/modules/XPCOMUtils.jsm"><span class="nowiki">resource://gre/modules/openLocationLastURL.jsm</span></a><span class="nowiki">");</span>
</pre>
<p>Once you've imported the module, you can then use the <code>gOpenLocationLastURL</code> object it exports. This object lets you fetch and change the URL that is placed in the "Open Location" dialog box when it opens.</p>
<div class="note"><strong>Note:</strong> This module automatically handles private browsing mode for you. The value preserved across accesses is not preserved when the user exits private browsing mode.</div>
<h2>Using the gOpenLocationLastURL object</h2>
<p>To get or set the value of the Open Location edit box, simply read the value of, or set the value of, the <code>gOpenLocationLastURL.value</code> field:</p>
<pre class="brush: js">var url = gOpenLocationLastURL.value;

<span class="plain">gOpenLocationLastURL.value = "http://www.mozilla.org/"; </span>
</pre>
<p>To reset the value of the edit box to the default (which is an empty string), you can call the <a class="internal" href="/en/JavaScript_code_modules/openLocationLastURL.jsm#reset()" title="en/JavaScript code modules/openLocationLastURL.jsm#reset()"><code>reset()</code></a> method:</p>
<h2>Method overview</h2>
<table class="standard-table"> <tbody> <tr> <td><code>reset()</code></td> </tr> </tbody>
</table>
<h2>Methods</h2>
<h3>reset</h3>
<p>The <span style="font-family: monospace;">reset</span><code>()</code> method resets the saved URL to the default, which is an empty string.</p>
<pre>reset();
</pre>
<h6>Parameters</h6>
<p>None.</p>
<h2>See also</h2>
<ul> <li><a class="internal" href="/en/JavaScript_code_modules/Using_JavaScript_code_modules" 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