Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-release > by-pkgid > dcb57bc1f616cf3a8072df2efbbf2767 > files > 95

elinks-0.12-18.mga7.i586.rpm

<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Chapter 15. Scripting ELinks with ECMAScript</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="The ELinks Manual"><link rel="up" href="index.html" title="The ELinks Manual"><link rel="prev" href="ch14s04.html" title="Example recipes"><link rel="next" href="ch15s02.html" title="ELinks Object"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 15. Scripting ELinks with ECMAScript</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch14s04.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="ch15s02.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter 15. Scripting ELinks with ECMAScript"><div class="titlepage"><div><div><h2 class="title"><a name="smjs-scripting"></a>Chapter 15. Scripting ELinks with ECMAScript</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="section"><a href="ch15.html#smjs-global-object">Global Object</a></span></dt><dd><dl><dt><span class="section"><a href="ch15.html#smjs-global-methods">Global Object Methods</a></span></dt><dt><span class="section"><a href="ch15.html#smjs-global-properties">Global Object Properties</a></span></dt></dl></dd><dt><span class="section"><a href="ch15s02.html">ELinks Object</a></span></dt><dd><dl><dt><span class="section"><a href="ch15s02.html#smjs-elinks-methods">ELinks Object Methods</a></span></dt><dt><span class="section"><a href="ch15s02.html#smjs-elinks-properties">ELinks Object Properties</a></span></dt><dt><span class="section"><a href="ch15s02.html#smjs-elinks-hooks">ELinks Object Hooks</a></span></dt></dl></dd><dt><span class="section"><a href="ch15s03.html">Cache Object</a></span></dt><dd><dl><dt><span class="section"><a href="ch15s03.html#smjs-cache_entry-properties">Cache Object Properties</a></span></dt></dl></dd><dt><span class="section"><a href="ch15s04.html">View-state Object</a></span></dt><dd><dl><dt><span class="section"><a href="ch15s04.html#smjs-view_state-properties">View-state Object Properties</a></span></dt></dl></dd></dl></div><p>As a user of ELinks, you can control its behaviour by writing scripts
in ECMAScript.  Unlike <a class="link" href="ch01s06.html" title="ECMAScript support?!">scripts in SCRIPT elements of HTML</a>, these user scripts run with all the permissions of your user
account, the same as with <a class="link" href="ch14.html" title="Chapter 14. Scripting ELinks with Lua">Lua</a>.  The object model is
very different too.</p><p>Support for ECMAScript user scripts was first added in ELinks 0.11.0.
The <code class="literal">configure</code> script enables it by default if the required SpiderMonkey
library has been installed, but you can disable it with <code class="literal">configure
--disable-sm-scripting</code> or by <a class="link" href="ch01s07.html#CONFIG-SCRIPTING-SPIDERMONKEY" title="ECMAScript (JavaScript) Browser Scripting (CONFIG_SCRIPTING_SPIDERMONKEY)">editing features.conf</a>.</p><div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Warning</h3><p>ECMAScript scripting is still a bit experimental: there seem to be
ways to crash ELinks with it, and the object model may change.  However, if
you don't have a <code class="literal">hooks.js</code> file, there is not much risk in enabling the
feature at compile time.</p></div><p>When ELinks starts up, it evaluates the ECMAScript file <code class="literal">hooks.js</code> in
your ELinks configuration directory (thus normally <code class="literal">~/.elinks/hooks.js</code>
on Unix-like systems), or if the file does not exist there, then in
the system-wide ELinks configuration directory (the location depends
on how ELinks was built, but <code class="literal">/etc/elinks/hooks.js</code> is typical).</p><p>In the ELinks source tree, the <code class="literal">contrib/smjs</code> directory contains some
examples about scripting ELinks with ECMAScript.  Please see the
<code class="literal">README</code> file in that directory for details.</p><div class="section" title="Global Object"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="smjs-global-object"></a>Global Object</h2></div></div></div><p>The global object provided to ECMAScript user scripts contains the standard
ECMAScript classes, as well as the following:</p><div class="section" title="Global Object Methods"><div class="titlepage"><div><div><h3 class="title"><a name="smjs-global-methods"></a>Global Object Methods</h3></div></div></div><div class="variablelist"><dl><dt><span class="term">
<a name="smjs-global.do_file"></a> do_file(path)
</span></dt><dd><p class="simpara">
        Load and evaluate the file with the given path (string). For example:
</p><pre class="screen">do_file("/home/me/.elinks/hooks.js");</pre><p class="simpara">will reload your hooks file.</p><p class="simpara"><span class="strong"><strong>Compatibility:</strong></span> ELinks 0.11.0</p></dd></dl></div></div><div class="section" title="Global Object Properties"><div class="titlepage"><div><div><h3 class="title"><a name="smjs-global-properties"></a>Global Object Properties</h3></div></div></div><div class="variablelist"><dl><dt><span class="term">
<a name="smjs-global.elinks"></a> elinks (elinks)
</span></dt><dd><p class="simpara">
        A reference to the <a class="link" href="ch15s02.html" title="ELinks Object">ELinks object</a>.
</p><p class="simpara"><span class="strong"><strong>Compatibility:</strong></span> ELinks 0.11.0</p></dd></dl></div></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch14s04.html">Prev</a> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="ch15s02.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Example recipes </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ELinks Object</td></tr></table></div></body></html>