JavaScript DHTML/Document/Selection — различия между версиями

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

Текущая версия на 07:20, 26 мая 2010

Clear a selection

    
<head>
<script language="JavaScript">
   function function1() {
       document.selection.clear();
   }
</script>
</head>
<body>
<p id="myP" contenteditable>
Select any part of it and click the button below.</p>
<button onclick="function1();">Delete selection</button>
</body>
</html>



Empty a selection

    
<html>
<body>
<script language="JavaScript">
function function1() {
    document.selection.empty();
}
</script>
<p onMouseUp="function1();">you release the mouse.</p>
<p>You can select text in this paragraph in various places.</p>
</body>
</html>



Selection type

    
<html>
<body onclick="alert(document.selection.type);">
<p>Select any element in the page</p>
<input type="text" value="Some text">
<input type="button" value="Some button">
</body>
</html>



Selection type Detail Example

    
<html>
<body>
<p>Select a portion of the sample text here. Then click the button</p>
<input type="button" value="Click here" onclick="alert(document.selection.typeDetail);">
</body>
</html>