Sunday, September 19, 2004

Changing the authentication mode in SQL Server


SUMMARY

After a Typical installation of Microsoft SQL Server 2000, Windows Authentication is the default security mode. Therefore, after you install SQL Server 2000 and you attempt to connect to the SQL Server server by using a standard login like system administrator (SA), you may receive the following error message:
Unable to connect to server SERVER_NAME:Server: Msg 18452, Level 16, State 1[Microsoft][ODBC SQL Server Driver][SQL Server]Login failed for user 'sa'. Reason: Not associated with a trusted SQL Server connection.
MORE INFORMATIONSQL Server 2000 has three types of installations:

  • Typical
  • Minimum

CustomFor more information about these installation types, refer to the "Setup Type: Typical, Minimum, or Custom" topic in Microsoft SQL Server Books Online.After you set up a SQL Server 2000 server by using the Setup Wizard to perform a Typical installation or by using the Sqlins.iss file for a typical unattended installation, the default security authentication mode is Microsoft Windows NT Authentication, which is different from Microsoft SQL Server 7.0. In SQL Server 7.0 the default authentication mode is Mixed (Windows NT Authentication Mode and SQL Server Authentication). You cannot use a SQL Server Standard security login account after a Typical installation of SQL Server 2000 until you change the authentication mode to Mixed.To change the authentication mode from Windows NT Authentication Mode (only) to Mixed Mode, use the following steps:

  1. Open the Enterprise Manager.
  2. Expand a Server group.
  3. Right-click a server name, and then click Properties.
  4. Click the Security tab.
  5. Under Authentication, click the SQL Server and Windows option button.
  6. Restart SQL Server in order for the change to take effect.

Microsoft SQL Server 2000 Authentication Mechanisms

Managing access to your databases

Building a secure and reliable database server involves both appropriate security means to be applied to the server as well as implementation of planned security assumptions to cover database objects. With a Microsoft SQL Server 2000 database that is firmly integrated with the Windows operating system, you can attain these goals with relatively little work. Let us therefore distinguish between four separate levels of database security control over access privileges:

  • Control over accessing the database at the server level, which applies to all databases. An appropriate configuration of remote access (over the network) to the system, on which the database server is installed - assigning permissions to user and group accounts in line with the organization’s security policy. Configuring Web servers to cover security oversights when databases are to be accessed at Web level; if need be additional security solutions like firewall setups or intrusion detection systems. However, discussing details of this level of security is not given consideration in this article. Of course, obtaining remote access to a system running SQL Server does not yet mean being granted access to the database server itself!
  • Control over accessing the SQL Server – at this stage, you can control access to databases with the components of the SQL Server security model for users that can access the server but not log in to the database server. Logging in to SQL Server gives a user permission to connect to SQL Server and work with minimum privileges in the master database but not to access all databases.
  • Regulating access to the SQL Server database is the next level of SQL Server security – each database managed by SQL Server has a list of valid users authorized to access it and using their logins to connect the server. Database administrators can set up logins and users in databases giving them permissions in accordance with the organization’s security policy. Each newly added user is given specific permissions that are valid for specific databases. In this manner, a user may obtain, for example, an administrator privilege (in the X database) whilst being a “normal” user (in the Y database) with no need to log in to these databases separately. The name of the database user is guest, and this guest account is used for logins without a user account of their own in a database. An SQL Server login has no rights to a database until you set up the login as a user of that database. The right to access a specific database does not automatically imply the right to execute any SQL (Structured Query Language) command on any database object.
  • The fourth level lets you assign permissions on objects in a database; for example, you can specify which tables or stored procedures a user can run and which views he can see. In fact, this means giving the user specific permissions to execute certain SQL commands on defined objects of the database.

Managing access to your Microsoft SQL Database Server 2000

With Microsoft SQL Database Server 2000 you can choose either of the two security (authentication) modes, namely:

  • NT security mode (Windows NT Authentication only),
  • Mixed mode (Windows NT Authentication and SQL Server Authentication).

In Windows NT mode, users that NT validates can also connect to SQL Server databases based on their user account names and group membership which already exist in Windows NT 4.0, Windows XP or Windows 2000.

In mixed mode, NT users connect to SQL Server databases under Windows NT mode and users that NT doesn’t validate use valid SQL Server (SQL Server Authentication) logins. Users that connect to SQL Server databases under Windows 2000 or Windows NT can make use of trusted connection mechanism for both authentication modes. Whenever the SQL Server database is connected, the access control mechanisms that in this case are lower level-ones (access to databases or database objects only) function identically in both authentication modes.

Windows NT Authentication Mode

This authentication mode is used by default because of its inherent better security. When it is used, Windows NT is responsible for managing users’ connections to the SQL Server through the user’s account name or group membership. In other words, database administrators can grant access to the database to the user or the user group specified in the Access Control List provided by the operating system. With this security mode, Server SQL tracks users by their individual SIDs (Security Identifiers) stored by the operating system itself.

Mixed authentication mode

With mixed authentication mode, it is possible that access to the SQL Server may be granted or denied, based on the access token created by the operating system (as in Windows NT Authentication mode). Also, SQL Server may take over the authentication process using a table containing login account information.

How is this control over database access seen from the user’s point of view? Windows NT Authentication mode can be used to manage database access in two instances. Firstly, if the Server SQL Administrator decides to choose this security mode and secondly, if the mixed mode is enabled. The user account available in the Microsoft Network domain is used to log in to SQL Server. The userid (stored in the operating system) is compared with the userids included in the ACLs of SQL Server. If it matches a valid userid, the validated user will be granted access to the databases (of course, to predefined databases only) with no need for password authentication.

Authentication provided by SQL Server itself is made only when the mixed mode is set. The mixed mode is enforced wherever the possibility to enable Windows NT Authentication mode exists. When may such a situation occur? You should choose mixed security mode when SQL Server is running on older Windows versions (less than 7.0), older platforms (Windows 9x and Windows Millennium) or for clients who cannot login to Microsoft Network (for example, Novell clients). In the case of access authentication, when a user connects to an SQL Server, then SQL Server uses a non-trusted connection that causes the client to use his credentials each time, i.e., login name and password, for authentication purposes. This data can of course be encrypted and stored locally; hence the SQL Server manages its own login validation process for all connections. The user name and password (forwarded to SQL Server mostly with the use of ADO objects) is checked against the credentials stored in ACL tables of SQL Server to grant or deny access to databases by the SQL Server.

Which option is better?

With Windows NT 4.0, Windows 2000 or Windows XP it is suggested to use Windows NT Authentication mode. Why? These Windows systems allow the creation of user accounts and groups. Therefore, this authentication mode may take advantage of the secure mechanism provided with these systems, namely trusted password matching and encryption, using minimum password length, password timeout or account lockout after multiple invalid login attempts. Defining user groups (and possibly their database roles) considerably helps in concurrently managing multiple database users.

Moreover, Windows NT validated users or groups may request access to databases without supplying their name and password. Any change to username or password under Windows does not therefore imply necessity to change application scripts. On the other hand, the SQL Server authentication mode requires that the user will supply its login and password while attempting to access a database or to change application scripts (if usernames or passwords are “buried” in the application script. This is obviously neither recommended, nor secure practice, but one must not exclude that user credentials are embedded in an application script, for example, this may happen with ASP scripts).

SQL Server Authentication mode is less secure – this is not a trusted connection that has provided for backward compatibility. It is also simpler to manage; i.e. SQL Server is wholly responsible for authenticating a user and for enforcing security restrictions on user credentials. From this point of view, it can be applied to execute control over access to non-critical organizational resources. For instance, you can create a single login on a SQL Server for all users to access a certain application instead of creating multiple user accounts or groups under Windows. Obviously, this means that monitoring activities of individual users becomes impracticable and impossible (SQL Profiler will naturally capture all access attempts, but any and all will be associated with the same user of the database). Managing users under the Windows Authentication mode rules, requires knowledge of issues related to creation of user accounts and groups within the operating system and also the necessary skills in using logins, roles and users in a database. However, notwithstanding a more complex process of administration, this mode allows one to impose more precise access restrictions and more efficiently manage multiple users.

Figure 1. Access control level in Ms SQL.

  • Light-green color denotes Web-related access permissions
  • Violet color denotes the MS SQL Server database access authentication process
  • Blue color indicates control over access to specific databases
  • Orange color indicates control over access to objects of a specific database in Ms SQL Server


What are the consequences?

If a user attempts to connect to SQL Server providing a null login name, then SQL Server uses Windows NT Authentication. In addition, if a user attempts to connect SQL Server under Windows NT Authentication mode and supplies the username, then this username will be ignored (login authentication is sufficient to authenticate the user at this point).

Some practical aspects

After enlightening (boring) readers with minute theoretical details, it is high time to provide some practical and useful information. The authentication mode can be set either during or after the installation of SQL Server 2000. Alterations to the authentication mode after installation can be made from the level of Enterprise Manager and Windows Register. In Enterprise Manager, click right mouse button on the SQL Server where you intend to introduce changes to the authentication mode, select “Properties" option and then go to the "Security" tab.

Figure 2. Setting the authentication mode in Ms SQL Server 2K from the Enterprise Manager's level.

Both the reading and modification of the authentication mode can be done using the Windows Register. To do this, first you must stop the MSSQLServer service (from another associated software program such as SQLServergent or DTC). Then launch the regedit.exe (or regedt32.exe) program. The security model can be changed by editing the following registry key:

HKLM\Software\Microsoft\MSSqlserver\MSSqlServer\LoginMode

or

HKLM\Software\Microsoft\Server Name_SQL\MSSqlServer\LoginMode

(depending on the parameters selected during the installation). The value of LoginMode can be 1 (Windows Authentication) or 2 (mixed mode). Setting the value of this registry key (DWORD type) you can establish the required security mode. If you have introduced any modifications, you must reboot SQL Server service.

Accessing a database from the application level is mostly done using Active Data Objects (Connection, Recordset and others). In the case of access to the Server database SQL (using SQLOLEDB) under Windows Authentication, you are not required to supply user credentials within the activating series to open the connection with database

"Provider=SQLOLEDB; Initial Catalog= Database_name; Data Source=Server_ name_SQL; Trusted_Connection=yes;"

In case of SQL Server Authentication, however, you must complement this information with user credentials:

"Provider=SQLOLEDB; Initial Catalog=Database_name; Data Source=Server_name_SQL; User ID=User_name; Password=Password;"

Choosing an appropriate SQL Server authentication option is important from both the administrator’s and the user’s point of view. It is responsible for secure access to the SQL Server, hence the Windows NT Authentication mode is widely recommended to be applied whenever possible. As was already mentioned, mixed mode may enforce the user to supply a login and password while attempting to access SQL Server. In addition, with this security mode, changes to the application scripts may be necessary (if both login and password are embedded in the script) whenever their values are modified.


Problem connecting MS SQL Server using JDBC

Using server 2k and sql 2k, and microsoft's JDBC sql driver. I keep getting an error:java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user 'Administrator'. Reason: Not associated with a trusted SQL Server connection.

That error means that you are trying to connect with sql authentication, but the server is set to window authentication mode.
to read about authentication modes:


http://www.windowsecurity.com/articles/SQL_Server_2000_Authentication.html

to change your authentication mode: http://support.microsoft.com/default.aspx?scid=kb;%5BLN%5D;269587

The JDBC connection can be used only with the mixed authentication mode:
"java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Login failed for user 'user'. Reason: Not associated with a trusted SQL Server connection.This error message occurs if the SQL Server 2000 authentication mode is set to Windows Authentication mode. The Microsoft SQL Server 2000 driver for JDBC does not support connecting by using Windows NT authentication. You must set the authentication mode of your SQL Server to Mixed mode, which permits both Windows Authentication and SQL Server Authentication"


http://support.microsoft.com/default.aspx?scid=kb;en-us;313100

Here's a code snippet:


import java.sql.*;
public class test1 {
public static void main(String[] args) throws Exception{
// Load the driver
Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
// Open connection
Connection conn = DriverManager.getConnection
("jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=sa");
// Prepare statement
PreparedStatement pstmt = conn.
prepareStatement("select * from t1 where x between ? and ?");
// Set parameters
pstmt.setInt(1, 990);
pstmt.setInt(2, 1000);
// Get result set
ResultSet rs = pstmt.executeQuery();
// Print it
while(rs.next() )
System.out.println("x: " + rs.getObject(1));
}
}


The connection string is in the following format:
jdbc:microsoft:sqlserver://localhost:1433;User=sa;Password=sa
You can substitute any DNS host name for localhost;User should exist in the DB and be authenticated by the DB not by Windows.

Solution for project folder not loading in tomcat 5

And the one i copied from the ROOT folder and changed a few things was



<?xml version="1.0" encoding="ISO-8859-1"?>



<web-app xmlns="http://java.sun.com/xml/ns/j2ee"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"

version="2.4">

<display-name>Java Servlet Book Examples</display-name>

<description>

Java Servlet Programming Test Programs

</description>

<servlet>

<servlet-name>helloworld</servlet-name>

<servlet-class>ch02.HelloWorld</servlet-class>

</servlet>

<servlet>

<servlet-name>askHello</servlet-name>

<servlet-class>ch02.Hello</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>helloworld</servlet-name>

<url-pattern>/servlet/HelloWorld</url-pattern>

</servlet-mapping>

<servlet-mapping>

<servlet-name>askHello</servlet-name>

<url-pattern>/servlet/Hello</url-pattern>

</servlet-mapping>

</web-app>

project folder not loadin in the tomcat 5.0

The web.xml i had from tomcat 4 was

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>
<display-name>Java Servlet Programming Examples</display-name>
<description>
Java Servlet Programming Examples.
</description>
<servlet>
<servlet-name>
helloWorld
</servlet-name>
<servlet-class>
HelloWorld
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
helloworld
</servlet-name>
<url-pattern>
/hello.html
</url-pattern>
</servlet-mapping>

</web-app>

Friday, September 17, 2004

Tomcat service not starting.

This error took my whole day. Khair, only if i would have asked forgiveness from Allah and pleaded infront of Him to make me to correctify this problem i would have done it in shorter span of time.
Khair, the solutions was that jre path has to be set to jre on c:

Thursday, September 16, 2004

HTML Events Objectwise

All HTML Events


1

Anchor Object

The Anchor object represents an HTML a element (a hyperlink).

For each instance of an HTML <a> tag in a document, an Anchor object is created.

An anchor can be used in two ways:

  1. To create a link to another document by using the href attribute
  2. To create a bookmark inside a document, by using the name attribute

All Anchor objects in a document can be found in the Document object's anchors array.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the link loses focus 2 3
onFocus Executes some code when the link gets focus 2 3

2

Area Object

The Area object defines an area of an image-map. An image-map is an image with clickable regions.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onClick Executes some code when a Click event occurs 3 4
onDblClick Executes some code when a Doubleclick event occurs 3 4
onMouseOut Executes some code when a Mouseout event occurs 3 4
onMouseOver Executes some code when a Mouseover event occurs 3 4

3

Button Object

The button object represents a push button on an HTML form.

For each instance of an HTML <input type="button"> tag on an HTML form, a Button object is created.

The Button objects are stored in the elements array of the corresponding form. You can access a Button object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the button loses focus 2 3
onClick Executes some code when the button is clicked 2 3
onFocus Executes some code when the button gets focus 2 3
onMouseDown Executes some code when a mouse button is pressed 4 4
onMouseUp Executes some code when a mouse button is released 4 4

4

Checkbox Object

The Checkbox object represents a checkbox on an HTML form.

For each instance of an HTML <input type="checkbox"> tag on an HTML form, a Checkbox object is created.

All Checkbox objects are stored in the elements array of the corresponding form. You can access a Checkbox object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the checkbox loses focus 2 3
onClick Executes some code when the checkbox is clicked 2 3
onFocus Executes some code when the checkbox gets focus 2 3
onMouseDown Executes some code when a mouse button is pressed 4 4
onMouseUp Executes some code when a mouse button is released 4 4

5

Document Object

The Document object is used to access all elements in a page.

Events

Syntax: document.event_name="someJavaScriptCode"

Event Description NN IE W3C
onClick Executes some code when a Click event occurs 6 5
onDblClick Executes some code when a Doubleclick event occurs 6 5
onFocus Executes some code when a Focus event occurs 6 5
onKeyDown Executes some code when a Keydown event occurs 6 5
onKeyPress Executes some code when a Keypress event occurs 6 5
onKeyUp Executes some code when a Keyup event occurs 6 5
onMouseDown Executes some code when a Mousedown event occurs 6 5
onMouseMove Executes some code when a Mousemove event occurs 6 5
onMouseOut Executes some code when a Mouseout event occurs 6 5
onMouseOver Executes some code when a Mouseover event occurs 6 5
onMouseUp Executes some code when a Mouseup event occurs 6 5
onResize Executes some code when a Resize event occurs 6 5

6

FileUpload Object

For each instance of an HTML <input type="file"> tag on a form, a FileUpload object is created.

All FileUpload objects are stored in the elements array of the corresponding form. You can access a FileUpload object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description NN IE W3C
onBlur Executes some code when the FileUpload object loses focus 3 4
onClick Executes some code when the FileUpload object gets a mouse click 3 4
onFocus Executes some code when the FileUpload object gets focus 3 4
onSelectStart Executes some code when the FileUpload object gets selected 4

7

Form Object

Forms are used to prompt users for input. We may use form elements such as text fields, radio buttons, checkboxes and selection lists. The input data is normally posted to a server for processing.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onReset Executes some code when a Reset event occurs 3 4
onSubmit Executes some code when a Submit event occurs 2 3

8

Frame Object

The Frame object represents an HTML frame.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the frame loses focus 5 No
onFocus Executes some code when the frame gets focus 5 No

9

Frameset Object

The Frameset object represents an HTML frameset.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the frameset loses focus 5 No
onFocus Executes some code when the frameset gets focus 5 No

10

IFrame Object

The IFrame object represents an HTML inline-frame.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the iframe loses focus 5 No
onFocus Executes some code when the iframe gets focus 5 No

11

Image Object

The Image object represents an HTML img element.

For each instance of an HTML <img> tag in a document, an Image object is created.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onAbort Executes some code when a user aborts the download of an image 3 4
onBlur Executes some code when the image loses focus 4
onClick Executes some code when a user clicks on the image 4
onError Executes some code when an Error occurs 3 4
onFocus Executes some code when the image gets focus 4
onLoad Executes some code when the image loads 3 4

12

Link Object

The Link object represents the HTML link element. The link element can only be used within the <head> tag.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onLoad Executes some code after the browser loads the link object 2 4

13

Password Object

For each instance of an HTML <input type="password"> tag on a form, a Password object is created.

All Password objects are stored in the elements array of the corresponding form. You can access a Password object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the password field loses focus 2 4
onClick Executes some code when the user clicks in the password field 4
onFocus Executes some code when the password field gets focus 2 3.02
onKeyDown Executes some code when a key is pressed down in the password field 4 4
onKeyPress Executes some code when an alphanumeric key is pressed in the password field 4 4
onKeyUp Executes some code when a key is released in the password field 4 4
onSelectStart Executes some code when some text in the password field is selected 4

14

Radio Object

For each instance of an HTML <input type="radio"> tag on a form, a Radio object is created.

All Radio objects are stored in the elements array of the corresponding form. You can access a Radio object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the radio button loses focus 2 4
onClick Executes some code when the user clicks on the radio button 4
onFocus Executes some code when the radio button gets focus 2 3.02
onSelectStart Executes some code when the radio button is selected 4

15

Reset Object

For each instance of an HTML <input type="reset"> tag on a form, a Reset object is created.

All Reset objects are stored in the elements array of the corresponding form. You can access a Reset object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the reset button loses focus 2 4
onClick Executes some code when the user clicks on the reset button 4
onFocus Executes some code when the reset button gets focus 2 3.02
onSelectStart Executes some code when the reset button is selected 4

16

Select Object

For each instance of an HTML <select> tag on a form, a Select object is created.

All Select objects are stored in the elements array of the corresponding form. You can access a Select object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the dropdown list loses focus 2 3.02
onChange Executes some code when the dropdown list loses focus and its value has altered 2 3.02
onClick Executes some code when the user clicks the left mouse button in the dropdown list 4
onFocus Executes some code when the dropdown list gets focus 2 4

17

Submit Object

For each instance of an HTML <input type="submit"> tag on a form, a Submit object is created.

All Submit objects are stored in the elements array of the corresponding form. You can access a Submit object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the submit button loses focus 4
onClick Executes some code when the user clicks on the submit button 2 4
onFocus Executes some code when the submit button gets focus 3.02
onSelectStart Executes some code when the submit button is selected 4 4

18

Table Object

The Table object represents an HTML table element.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the table loses focus 4
onClick Executes some code when the user clicks on the table 4
onFocus Executes some code when the table gets focus 4
onSelectStart Executes some code when the table is selected 4

19

TableData Object

The TableData object represents an HTML td element.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the table cell loses focus 4
onClick Executes some code when the user clicks on the table cell 4
onFocus Executes some code when the table cell gets focus 4
onSelectStart Executes some code when the table cell is selected 4

20

TableHeader Object

The TableHeader object represents an HTML th element.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the table header cell loses focus 5
onClick Executes some code when the user clicks on the table header cell 4
onFocus Executes some code when the table header cell gets focus 5
onSelectStart Executes some code when the table header cell is selected 4

21

TableRow Object

The TableRow object represents an HTML tr element.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the table row loses focus 4
onClick Executes some code when the user clicks on the table row 4
onFocus Executes some code when the table row gets focus 4
onSelectStart Executes some code when the table row is selected 4

22

Text Object

For each instance of an HTML <input type="text"> tag on a form, a Text object is created.

All Text objects are stored in the elements array of the corresponding form. You can access a Text object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the text field loses focus 2 4
onChange Executes some code when the text field loses focus and its value has altered 2 3.02
onClick Executes some code when the user clicks the left mouse button in the text field 4
onFocus Executes some code when the text field gets focus 2 3.02
onKeyDown Executes some code when a key is pressed in the text field 4 4
onKeyPress Executes some code when an alphanumeric key is pressed in the text field 4 4
onKeyUp Executes some code when a key is released in the text field 4 4
onSelect Executes some code when the current selection is changed in the text field 2 3.02
onSelectStart Executes some code when some text in the text field is selected 4

23

Textarea Object

For each instance of an HTML <textarea> tag on a form, a Textarea object is created.

All Textarea objects are stored in the elements array of the corresponding form. You can access a Textarea object by indexing this array - either by number (0 represents the first element in a form) or by using the value of the name attribute.

Events

Syntax: object.event_name="someJavaScriptCode"

Event Description N IE W3C
onBlur Executes some code when the textarea loses focus 2 3.02
onChange Executes some code when the textarea loses focus and its value has altered 2 3.02
onClick Executes some code when the user clicks the left mouse button in the textarea 4
onFocus Executes some code when the textarea gets focus 2 3.02
onKeyDown Executes some code when a key is pressed down in the textarea 4
onKeyPress Executes some code when a key is pressed in the textarea 4
onKeyUp Executes some code when a key is released in the textarea 4
onSelect Executes some code when some text in the textarea is selected 2

24

Window Object

The Window object corresponds to the browser window. A Window object is created automatically with every instance of a <body> or <frameset> tag.

Events

Syntax: window.event_name="someJavaScriptCode"

Event Description N IE
onBlur Executes some code when a Blur event occurs 3
onError Executes some code when an Error event occurs 3
onFocus Executes some code when a Focus event occurs 3
onLoad Executes some code when an Load event occurs 2
onResize Executes some code when a Resize event occurs 4
onUnload Executes some code when an Unload event occurs 2


Important links

http://codepunk.hardwar.org.uk/index.htm

http://www.w3schools.com/htmldom/dom_obj_select.asp

http://www.ucl.ac.uk/SLAIS/rob-miller/lectures/P018/#Lectures

http://scriptsearch.com/Java/

http://msdn.microsoft.com/library/default.asp?url=/workshop/author/dhtml/dhtml_node_entry.asp

HTML DOM Document Object

Document Object

The Document object is used to access all elements in a page.

The Document object's collections, properties, methods, and events are described below:

N: Netscape (including Mozilla when N6 or higher), IE: Internet Explorer, W3C: World Wide Web Consortium (Internet Standard), D: Deprecated

Collections

Collection Description N IE W3C
anchors[] Returns a reference to all Anchor objects in the document 2 3 Yes
applets[] Returns a reference to all Applet objects in the document 3 4 Yes
attributes[] 6 - No
childNodes[] 6 5 No
embeds[] Returns a reference to all embedded objects in the document 3 4 No
forms[] Returns a reference to all Form objects in the document 2 3 Yes
images[] Returns a reference to all Image objects in the document 3 4 Yes
links[] Returns a reference to all Link objects in the document 2 3 Yes
plugins[] 6 - No
sylesheets[] 6 5 No

Properties

Syntax: document.property_name

Property Description N IE W3C
alinkColor Sets or returns the color of the active links in the document 2 3 D
bgColor Sets or returns the background-color of the document 2 3 D
body Specifies the beginning and end of the document body 6 5 Yes
cookie Sets or returns all cookies associated with the document 2 3 Yes
documentElement Returns a reference to the root node of the document 6 5 No
domain Returns the document server's domain name 3 4 Yes
fgColor Sets or returns the text-color of the document 2 3 D
lastModified Returns the date and time the document was last modified 2 3 No
linkColor Sets or returns the color of the links in the document 2 3 D
referrer Returns the URL of the document that loaded the current document 2 3 Yes
title Returns the title of the document (text inside the HTML title element) 2 3 Yes
URL Returns the URL of the current document 3 4 Yes
vlinkColor Sets or returns the color of the visited links in the document 2 3 D

Methods

Syntax: document.method_name()

Method Description N IE W3C
clear() Clears all elements in the document 2 - No
close() Closes the output stream and displays the sent data 2 3 Yes
createAttribute("name") Creates an attribute with a specified name 6 6 No
createElement("tag") Creates an element 6 5 No
createTextNode("txt") Creates a text string 6 5 No
focus() Gives the document focus 6 5 No
getElementById("id") Returns a reference to the first object with the specified ID 6 5 No
getElementsByName("name") Returns a collection of objects with the specified NAME 6 5 Yes
getElementsByTagName("tag") Returns a collection of objects with the specified TAGNAME 6 5 No
open("mimetype"[,replace]) Opens a document for writing. If a document exists in the target it will be cleared. If this method has no arguments, a new window with about:blank is displayed 2 3 Yes
write("str") Writes a text string to a document opened by open() 2 3 Yes
writeln("str") Writes a text string followed by a new line character to a document opened by open() 2 3 Yes

Events

Syntax: document.event_name="someJavaScriptCode"

Event Description NN IE W3C
onClick Executes some code when a Click event occurs 6 5
onDblClick Executes some code when a Doubleclick event occurs 6 5
onFocus Executes some code when a Focus event occurs 6 5
onKeyDown Executes some code when a Keydown event occurs 6 5
onKeyPress Executes some code when a Keypress event occurs 6 5
onKeyUp Executes some code when a Keyup event occurs 6 5
onMouseDown Executes some code when a Mousedown event occurs 6 5
onMouseMove Executes some code when a Mousemove event occurs 6 5
onMouseOut Executes some code when a Mouseout event occurs 6 5
onMouseOver Executes some code when a Mouseover event occurs 6 5
onMouseUp Executes some code when a Mouseup event occurs 6 5
onResize Executes some code when a Resize event occurs 6 5



HTML DOM Window Object

Window Object

The Window object corresponds to the browser window. A Window object is created automatically with every instance of a <body> or <frameset> tag.

The Window object's collections, objects, properties, methods, and events are described below:

N: Netscape (including Mozilla when N6 or higher), IE: Internet Explorer

Collections

Collection Description N IE
frames[] Returns all named frames in the window 2 3.02

Objects

Object Description N IE
clientInformation Contains information about the browser 4
clipboardData 5
document Represents the HTML document object in the window. See'>http://www.w3schools.com/htmldom/dom_obj_document.asp">See Document object 3.02
event Represents the state of an event 4
external 4
history Contains the URLs visited from the window. See'>http://www.w3schools.com/htmldom/dom_obj_history.asp">See History object 3.02
location Contains the current URL of the window. See'>http://www.w3schools.com/htmldom/dom_obj_location.asp">See Location object 3.02
navigator Contains information about the browser. See'>http://www.w3schools.com/htmldom/dom_obj_navigator.asp">See Navigator object 3.02
screen Contains information about the client's screen. See'>http://www.w3schools.com/htmldom/dom_obj_screen.asp">See Screen object 4

Properties

Syntax: window.property_name

Property Description N IE
closed Returns a Boolean value that specifies whether the referenced window has been closed 3 4
defaultStatus Sets or returns the default text in the statusbar of the windows (will be displayed when the page loads) 2 3.02
dialogArguments Returns all variables passed into the modal dialog window 4
dialogHeight Sets or returns the height of the modal dialog window 4
dialogLeft Sets or returns the left coordinates of the modal dialog window 4
dialogTop Sets or returns the top coordinates of the modal dialog window 4
dialogWidth Sets or returns the width of the modal dialog window 4
frameElement Returns the frame/iframe object that is hosting the window in the parent document 5.5
length Sets or returns the number of frames in the window 6 4
name Sets or returns the name of the window 2 3.02
offscreenBuffering Sets or returns a Boolean value that specifies whether the window is drawn offscreen before being visible to the user 4
opener Sets or returns a reference to the window that created the window 3 4
parent Returns the parent window 2 3.02
returnValue Sets or returns the value returned from the modal dialog window 4
screenLeft Returns the x-coordinate of the upper left corner of the browser - relative to the upper left corner of the screen 5
screenTop Returns the y-coordinate of the top corner of the browser - relative to the top corner of the screen 5
self Returns a reference to the current window 2 3.02
status Sets or returns the text in the statusbar of the window 2 3.02
top Returns the topmost ancestor window 2 3.02

Methods

Syntax: window.method_name()

Method Description N IE
alert("msg") Displays an alert box with a message and an OK button 2 3.02
attachEvent("event",pointer) 5
blur() Removes focus from the current window 3 4
clearInterval(ID) Cancels a timeout that is set with the setInterval() method 4 4
clearTimeout(ID) Cancels a timeout that is set with the setTimeout() method 2 3.02
close() Closes the current window 2 3.02
confirm("msg") Displays a dialog box with a message, a Cancel, and an OK button 2 3.02
createPopup([args]) Creates a pop-up window 5.5
execScript("code", "lang") Executes a specified script. The arguments can take the following values:
code Required. The code to be executed
lang Required. JScript VBScript JavaScript


4
focus() Sets focus on the current window 3 4
moveBy(x,y) Moves the window a specified number of pixels in relation to its current co-ordinates 4 4
moveTo(x,y) Moves the window's left and top edge to the specified co-ordinates 4 4
navigate("URL") Loads the specified URL into the window 3.02
open(["URL", "name", "specs", replace]) Opens a new browser window. The arguments can take the following values:

"URL" - Optional. Specifies the URL of the page to display if no URL is specified, a new window with about:blank is displayed)

"name" - Optional. Specifies the value for the target attribute on a form or a link. The following values are supported:

_blank URL is loaded into a new window
_media URL is loaded into the content area of the Media Bar (IE6+)
_parent URL is loaded into the parent frame
_search URL is opened in the browser's search pane (IE5+)
_self URL replaces the current page
_top URL replaces any framesets that may be loaded

"specs" - Optional. A comma-separated list of items. The following values are supported:

channelmode = yes no 1 0 whether to display the window in theater mode. Default is no
directories = yes no 1 0 whether to add directory buttons. Default is yes
fullscreen = yes no 1 0 whether to display the browser in full-screen mode. Default is no. A window in full-screen mode must also be in theater mode
height = number the height of the window, in pixels. Min. value is 100
left = number the left position, in pixels
location = yes no 1 0 whether to display the address field. Default is yes
menubar = yes no 1 0 whether to display the menu bar. Default is yes
resizable = yes no 1 0 whether the window is resizable. Default is yes
scrollbars = yes no 1 0 whether to display scroll bars. Default is yes
status = yes no 1 0 whether to add a status bar. Default is yes
titlebar = yes no 1 0 whether to display the title bar. Ignored unless the calling application is an HTML Application or a trusted dialog box. Default is yes
toolbar = yes no 1 0 whether to display the browser toolbar. Default is yes
top = number the top position, in pixels
width = number the width of the window, in pixels. Min. value is 100
width = number the width of the window, in pixels. Min. value is 100

replace - Optional.Specifies whether the URL creates a new entry or replaces the current entry in the history list. The following values are supported:

true URL replaces the current document in the history list
false URL creates a new entry in the history list


3.02
print() Prints the contents of the current window 4 5
prompt(["msg", "default"]) Displays a dialog box prompting the user for input. The arguments can take the following values:
msg Optional. The message to display in the dialog box. Default is ""
default Optional. The default text in the input field


2 3.02
resizeBy(x,y) Resizes the window by the specified pixels. Note: This method does not work on dialog windows 4
resizeTo(width, height) Resizes the window to the specified width and height. Note: This method does not work on dialog windows 4
scroll(x,y) Deprecated. Use scrollTo() instead. 4
scrollBy(x,y) Scrolls the content by the specified number of pixels. Note: The visible property of the window's scrollbar must be set to true if using this method 4 4
scrollTo(x,y) Scrolls the content to the specified co-ordinates 4 4
setActive() 5.5
setInterval(code, millisec[, "lang"]) Calls a function / evaluate an expression every time a specified interval (in milliseconds) has been reached. The arguments can take the following values:
code Required. A pointer to a function or the code to be executed
millisec Required. The number of milliseconds
lang Optional. JScript VBScript JavaScript


4 4
setTimeout(code, millisec[, "lang"]) Calls a function / evaluate an expression after a specified number of milliseconds. The arguments can take the following values:
code Required. A pointer to a function or the code to be executed
millisec Required. The number of milliseconds
lang Optional. JScript VBScript JavaScript


3.02
showHelp("URL"[, contextID]) Displays a Help file (must be of type .htm or .chm). When using this method, a second Help box appears when pressing F1 or when clicking Help on the menu bar. To prevent the default Help box from appearing set returnValue to false. The arguments can take the following values:
URL Required. The URL of a Help file
contextID Optional. A string or integer that specifies a context identifier in the Help file


4
showModalDialog("URL"[, args, "list"]) Loads a URL in a modal dialog box. A modal dialog box retains focus while open. The user CANNOT switch windows until the dialog box is closed. The arguments can take the following values:

"URL" - Required. The URL of the document to display.

args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object.

"list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:

dialogHeight : number the height* of the dialog window
dialogLeft : number the left position of the dialog window
dialogTop : number the top position of the dialog window
dialogWidth : number the width* of the dialog window
center : yes no 1 0 on off whether to center the dialog window within the desktop. Default is yes
dialogHide : yes no 1 0 on off whether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
edge : sunken raised the edge style of the dialog window. Default is raised
help : yes no 1 0 on off whether the dialog window displays the Help icon. Default is yes
resizable : yes no 1 0 on off whether the dialog window is resizable. Default is no
scroll : yes no 1 0 on off whether the dialog window displays scrollbars. Default is yes
status : yes no 1 0 on off whether the dialog window displays a status bar. Default is yes for untrusted dialog windows and no for trusted dialog windows
unadorned : yes no 1 0 on off whether the dialog window displays the border window chrome. Only available when a dialog window is opened from a trusted application. Default is no


4
showModelessDialog("URL"[, args, "list"]) Loads a URL in a modeless dialog box. The modeless dialog box displays even when the user switches focus to another window (useful for menus and Help systems). The arguments can take the following values:

"URL" - Required. The URL of the document to display.

args - Optional. The arguments to use when displaying the URL. Use this parameter to pass a value of any type, including an array of values. The dialog box can extract the values from the dialogArguments property of the window object.

"list" - Optional. Specifies the window ornaments for the dialog box, using one or more of the following semicolon-delimited values:

dialogHeight : number the height* of the dialog window
dialogLeft : number the left position of the dialog window
dialogTop : number the top position of the dialog window
dialogWidth : number the width* of the dialog window
center : yes no 1 0 on off whether to center the dialog window within the desktop. Default is yes
dialogHide : yes no 1 0 on off whether the dialog window is hidden when printing. Only available when a dialog box is opened from a trusted application. Default is no
edge : sunken raised the edge style of the dialog window. Default is raised
help : yes no 1 0 on off whether the dialog window displays the Help icon. Default is yes
resizable : yes no 1 0 on off whether the dialog window is resizable. Default is no
scroll : yes no 1 0 on off whether the dialog window displays scrollbars. Default is yes
status : yes no 1 0 on off whether the dialog window displays a status bar. Default is yes for untrusted dialog windows and no for trusted dialog windows
unadorned : yes no 1 0 on off whether the dialog window displays the border window chrome. Only available when a dialog window is opened from a trusted application. Default is no


5

* The default unit of measure for dialogHeight and dialogWidth in IE4 is em; in IE5 it is px. Other values to use: cm, mm, in, pt, pc, or ex. For consistent results, use px! Note: The min. dialogHeight you can specify is 100px.

Events

Syntax: window.event_name="someJavaScriptCode"

Event Description N IE
onBlur Executes some code when a Blur event occurs 3
onError Executes some code when an Error event occurs 3
onFocus Executes some code when a Focus event occurs 3
onLoad Executes some code when an Load event occurs 2
onResize Executes some code when a Resize event occurs 4
onUnload Executes some code when an Unload event occurs 2