Difference between revisions of "Category:Javascript"

From FreeSWITCH Wiki
Jump to: navigation, search
m (minor fix-up)
(fsession.com is defunct)
Line 51: Line 51:
* [[Javascript_Event]]
* [[Javascript_Event]]
* [[Javascript_XML]]
* [[Javascript_XML]]
* [http://www.fsession.com fsession website] - A new JavaScript library for working with FreeSWITCH

Revision as of 22:19, 21 January 2013

FreeSWITCH uses the Mozilla SpiderMonkey JavaScript (ECMAScript) engine. It supports all the standard JavaScript language elements, for example 'for' and 'while' loops, regexps, etc. In addition there are things that are specific to FreeSWITCH which are listed below. You need to have mod_spidermonkey compiled and installed to take advantage of these functions. Each of those sections are documented below.



mod_spidermonkey is now built and installed by default as of Rev 5787 (1.0.beta2 tag and beyond)

If for some reason it's not, do the following:

  • Uncomment languages/mod_spidermonkey in modules.conf in your src directory (make it always build and install spidermonkey)
  • Run 'make mod_spidermonkey-install' to make and install just the spidermonkey module
  • Edit conf/autoload_configs/modules.conf.xml in your FreeSWITCH™ install directory to load mod_spidermonkey
  • Restart freeswitch

For database support you will need an additional module compiled and installed. See the mod_spidermonkey_odbc page for installation instructions.

Informational Tip

Note: if you are using Fedora and you have errors like /lib/libnssutil3.so: undefined symbol: PR_GetEnv, you will need to configure FreeSWITCH using the --without-libcurl switch. Download_&_Installation_Guide#Fedora


Execution of a script

There are two methods for script execution, via an API call jsrun and via an application javascript. When you use the API a default Session object is not created, as there is no call to associate it with. By default, scripts will be loaded from the {FS_ROOT}/scripts directory, you may override this by placing a / as the first character in Unix-like systems or a x:\ in Windows systems as the script name.


From the Dialplan, you simply call it as an application similar to:

<action application="javascript" data="/path/to/some/script.js"/>

If you need to pass arguments into to the javascript application, they can be passed in as a single string to the variable "argv" by doing the following:

<action application="javascript" data="/path/to/some/script.js $1"/>


At the FreeSWITCH™ console, or some other application/interface execute the jsrun call with the script name as its argument.

jsrun /path/to/some/script.js


Function Reference

SpiderMonkey Specific Objects

  • File - File IO methods (Spidermonkey object)

Other Points Of Interest


See Also

Pages in This Category


This category has only the following subcategory.

Pages in category "Javascript"

The following 146 pages are in this category, out of 146 total.








J cont.


M cont.