You are here: Reference > JavaScript > client-side > selection and ranges > methods > intersectsNode (Range)
intersectsNode method (Range)
3 |
Returns whether the specified node and the current Range object have an intersection.
Note: The support for the intersectsNode method has been removed in Firefox 3. Use the compareBoundaryPoints method instead.
Syntax:
You can find the related objects in the Supported by objects section below.
Parameters:
Required. Reference to the node to check. |
Return value:
Boolean. One of the following values:
The specified node and the current Range object have no intersection. | |
The specified node and the current Range object have an intersection. |
Example HTML code 1:
This example illustrates the use of the intersectsNode method:
|
||||
<head> <script type="text/javascript"> function TestPlacement () { var boldText = document.getElementById ("boldText"); if (window.getSelection) { // all browsers, except IE before version 9 var selection = window.getSelection (); if (selection.rangeCount > 0) { var selRange = selection.getRangeAt (0); if (selRange.intersectsNode) { // Firefox earlier than version 3, Google Chrome, Safari, Opera if (selRange.intersectsNode (boldText)) { alert ("The selection intersects the bold text."); } else { alert ("The selection and the bold text have no intersection."); } } else { alert ("Your browser does not support this example!"); } } else { alert ("Please select some content!"); } } else { alert ("Your browser does not support this example!"); } } </script> </head> <body> Select some text on this page and use the following button to get information about the placement of the <b id="boldText">bold text</b> relative to the selection. <br /><br /> <button onclick="TestPlacement ();">Test placement</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments