Using the document.selection Object : Text HTML : HTML : JavaScript DHTML examples (example source code) Organized by topic

JavaScript DHTML
C++
PHP


JavaScript DHTML  »  HTML   » [  Text HTML  ]   
 



Using the document.selection Object

<HTML>
<HEAD>
<TITLE>selection Object</TITLE>
<SCRIPT LANGUAGE="JavaScript">
function processSelection() {
    if (document.choices.process[0].checked) {
        status = "Selection is type: " + document.selection.type
        setTimeout("emptySelection()"1000)
    else if (document.choices.process[1].checked) {
        var rng = document.selection.createRange()
        document.selection.clear()
    }
}
function emptySelection() {
    document.selection.empty()
    status = "Selection is type: " + document.selection.type
}
</SCRIPT>
</HEAD>
<BODY>
<H1>IE selection Object</H1>
<HR>

<FORM NAME="choices">
<INPUT TYPE="radio" NAME="process" CHECKED>De-select after two seconds<BR>
<INPUT TYPE="radio" NAME="process">Delete selected text.
</FORM>
<P onMouseUp="processSelection()">
Text, Text, Text, Text, Text, Text, Text, Text, Text, Text, Text, 
Text, Text, Text, Text, Text, Text, Text, Text, Text, Text, 
Text, Text, Text, Text, Text, Text, Text, Text, Text, 
Text, Text, Text, Text, Text, Text, Text, 
Text, Text, Text, Text, Text, Text, Text, 
Text, 
</BODY>
</HTML>

           
       
Related examples in the same category
1.  An example of a scrolling message
2.  Animating Text Styles
3.  Moving Text
4.  Using the TextRectangle Object Properties
5.  Exploring the Bounding TextRange Properties
6.  compareEndPoints() Method
7.   Two Search and Replace Approaches (with Undo)
8.  Encipher and DecipherHas Download File
























Home| Contact Us
Copyright 2003 - 07 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.