JavaScript DHTML/Document/Selection

Материал из Web эксперт
Перейти к: навигация, поиск

Clear a selection

   <source lang="html4strict">
   

<head> <script language="JavaScript">

  function function1() {
      document.selection.clear();
  }

</script> </head> <body>

Select any part of it and click the button below.

<button onclick="function1();">Delete selection</button> </body> </html>


     </source>
   
  


Empty a selection

   <source lang="html4strict">
   

<html> <body> <script language="JavaScript"> function function1() {

   document.selection.empty();

} </script>

you release the mouse.

You can select text in this paragraph in various places.

</body> </html>


     </source>
   
  


Selection type

   <source lang="html4strict">
   

<html> <body onclick="alert(document.selection.type);">

Select any element in the page

<input type="text" value="Some text"> <input type="button" value="Some button"> </body> </html>


     </source>
   
  


Selection type Detail Example

   <source lang="html4strict">
   

<html> <body>

Select a portion of the sample text here. Then click the button

<input type="button" value="Click here" onclick="alert(document.selection.typeDetail);"> </body> </html>


     </source>