Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

removeAllRanges method

Removes all ranges from a selection.

HTML5 A vocabulary and associated APIs for HTML and XHTML, Section 7.6.1Internet Explorer 9

 

Syntax

var retval = HTMLSelection.removeAllRanges();

Parameters

This method has no parameters.

Return value

Type: HRESULT

If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Standards information

Remarks

removeAllRanges can remove invisible carets or insertion points that result when the Collapse method is applied to a selection.

Examples

This example uses removeAllRanges to clear a selection from text or elements.


<!DOCTYPE html>
<html>
    <head>
    <title>Remove All Ranges Example</title>        
        <script type="text/javascript">
        function removeAllRangesDemo() {
        if (window.getSelection){                       //check for a selection
            var selection = window.getSelection();      //get a selection object
            selection.removeAllRanges();                //remove all ranges
            }     
        }
    </script>
    </head>
    <body>
<h1>Remove all ranges example</h1>
<p>Select some text or elements on this page. When you click the button below, the selection will be cleared. </p>
<h2>h2 header</h2>
<p>Some more sample text to <strong>delete</strong>.</p>  
<input type="button" value="Remove all Ranges" onclick="removeAllRangesDemo()"   />   
    </body>
</html>

See also

HTMLSelection
collapse

 

 

Show:
© 2016 Microsoft