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

/*
JavaScript Bible, Fourth Edition
by Danny Goodman 

Publisher: John Wiley & Sons CopyRight 2001
ISBN: 0764533428
*/

<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()"2000)
    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()">Lorem ipsum dolor sit amet, consectetaur
 adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
 magna aliqua. Ut enim adminim veniam, quis nostrud exercitation ullamco
 laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
 reprehenderit involuptate velit esse cillum dolore eu fugiat nulla pariatur.
</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.  Lab for 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.