Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

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


HRESULT retVal = object.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

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

Examples

This example uses IHTMLSelection::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

IHTMLSelection::collapse

 

 

Community Additions

ADD
Show:
© 2015 Microsoft