JavaScript API

Welcome

Login to contribute. Register if you haven't yet.

Support Options

1. Search this site.
2. Make or vote for a Suggestion.
3. Post to Community Support.
3. Contact EditMe Support staff.

Stay Informed

Keep informed of product changes, tutorials and tips via EditMe's Blog and monthly newsletter.

JavaScript API Class: Server

The Server class is accessible from the "server" implicit object. It contains properties and methods to manage communication between the browser client and the server.

Properties

Name  Type  Access
Description 
domain
String
read
The domain that was used to make the current request. For a request of http://www.editme.com/Home, the domain returned would be "www.editme.com".
method
String
read
Returns the HTTP method that was used to make the current request.Typically this is either "GET" or "POST". This can be used by scripts that modify data to check for a POST method before changing data. Otherwise search spiders can unwittingly modify data by crawling the site.
requestParameters Array of Strings
read
An array of request parameters, including both form post and querystring parameters. For a request of  http://www.editme.com/Home?version=1, this property would return a single entry array containing 'version'.
scheme
String
read
The scheme that was used to make the current request. For a request of http://www.editme.com/Home, the scheme returned would be "http".
sessionID
String read
A unique identifier for the current user's session. This is used to allow anonymous users to edit their own comments for the duration of the session in which they were posted.
URL
String
read
The full URL of the request including the querystring. For example, http://www.editme.com/Home?version=1
visitorIP String read Returns the IP address of the user making the current request in the form "###.###.###.###".

Functions

Name  Return Type
Description 
captchaTest(String)  Boolean
Returns true if the given string matches the last string represented in a Captcha for the current user. This allows custom forms to use the /Captcha.jpg image in forms.
cookie (String) String
Returns the value of the cookie with the name provided in the String argument. If a cookie of that name is not found, an empty string is returned.
cookie (String1, String2, Number)
None
Sets a cookie named String1 to a value of String2. The Number argument is the number of days the cookie should survive. If a negative number, the cookie will expire with the browser session. 
noCache ()  None  Instructs the server not to cache this page. EditMe caches page responses, such that a dynamic script may not be executed with every request. For example, a page counter script should not be cached. This function should be used sparingly as it can significantly effect site performance - cached pages are served as much as 100 times faster than non-cached pages. For example, a page counter script should be isolated into a minimal script that only performs the page counter functionality, and noCache() should be called within that script. EditMe suggests developers seek advice from Support before using this function to minimize its performance impact.
newEmail()
Email
Creates a new instance of the Email class to send an email message.
print (String)
None  Writes a string to output if this is a Raw output script. See Raw JavaScript Output for usage details. 
redirect (String)  None
Redirects the browser to another location, specified by String. This can be a relative (/SomePage) or full URL (http://www.editme.com). 
request (String)
String
Returns a value for the named request parameter, including form and querystring parameters. If the named parameter does not exist, an empty string is returned. 
requests (String)  Array of String
Returns an array of string values for a request parameter. This should be used when a field name is expected to be submitted multiple times, as happens with check boxes, for example.
paramExists(String)  Boolean
Returns true if the named parameter was included in the query string or form post.
securityKey (User)
String
Returns an MD5 hash of the user's name and session ID.

Example

// set a cookie for 30 days
server.cookie ('TestCookie', 'Some Text', 60*60*24*30);
// retrieve the stored cookie value
var val = server.cookie('TestCookie')

 

Return to JavaScript API