JavaScript Selections: General Selections - Doc JavaScript | WebReference

JavaScript Selections: General Selections - Doc JavaScript


General Selections

In Navigator 4.0x it is only possible to select text. For example, when you drag the mouse over an image, the image is not highlighted. The browser simply selects the text before and after the image, based on the document flow. The height of the selection depends on the size of the text. It is not possible to find out what type of text is selected.

Internet Explorer 4.0x differs from Navigator 4.0x in many ways. In Internet Explorer 4.0x it is possible to select almost any element on the page. For example, you can select text, images, and buttons. However, some elements, such as SELECT menus, cannot be selected.

Unlike most other programs, a selection in Navigator 4.0x remains active (highlighted) even if focus is removed from the page. For example, if you drag the mouse over a portion of the document, and then click a button on the page, Navigator 4.0x doesn't deselect the text. As opposed to Navigator 4.0x, a selection in Internet Explorer 4.0x is deactivated when focus is removed from the selected element. For instance, when you click a button on the page, the browser deselects the current selection.

In both fourth-generation browsers, the selection is deactivated when you select a portion of the document, and then click a link. Therefore, you cannot implement a script that asks the user to click a link in order to execute a script that displays the current selection. We'll take advantage of the new events in Navigator 4.0x and Internet Explorer 4.0x to display the user's selection when he or she releases the mouse button. In other words, we'll evaluate the selection when a mouseup event occurs.

http://www.internet.com


Created: January 29, 1998
Revised: January 29, 1998

URL: http://www.webreference.com/js/column12/general.html