aaaa
<input onclick="alert(document.selection.createRange().text)" type=button value=get>
<input onclick="alert(document.selection.createRange().text)" type=button value=get>
解决方案 »
- 请教各位大大,如何在html代码中利用JS返回取值!
- EXT问题
- 刚刚我问的问题,关于取INPUT的值.
- 求个正则:寻找某个单独字符后跟随的数字
- 关于三级联动的问题!!(急!!!!!!!!!!)
- 如何解决用表单名称和文本框名称作为参数呢?
- 问:如何给表单赋值!
- 在js中如何去掉两端的空格?
- 请问:如何判断客户端是否已安装了某一控件(OCX)?
- 400分求解!!! 给外网https网页动态加载的本地JS不执行
- 也是关于PHP中调用javascript的值的问题,谢谢
- 如何通過javascript來得到本頁的全部html代碼(再通過alert function來將其展示出來)?如何能通過點擊按鈕來使
<html>
<head>
<script language="JavaScript">
document.onselectionchange = doChange;
function doChange(){
if(document.selection.type=="None") return;
t = document.selection.createRangeCollection();
sel.value="";
for(i=0; i<t.length; i++)
sel.value += t(i).text;
}
</script>
</head>
<body>
To retrieve a text range object, apply the createTextRange method to a body, BUTTON, or TEXTAREA element or an INPUT element that has TYPE text.
<button>INPUT element</button>Modify the extent of the text range by moving its start and end positions with methods such as move, moveToElementText, and findText. Within the text range, you can retrieve and modify plain text or HTML text. These forms of text are identical except that HTML text includes HTML tags, and plain text does not. This object is available in script as of Microsoft?Internet Explorer
<textarea id=sel cols=80 rows=20></textarea>
</body>
</html>
那document.selection.createRangeCollection()又是什么意思?跟上面creatRange()有什么关系吗?
<head>
<script language="JavaScript">
document.onselectionchange = doChange;
function doChange(){
sel.value = document.selection.createRange().text;
}
</script>
</head>
<body>
To retrieve a text range object, apply the createTextRange method to a body, BUTTON, or TEXTAREA element or an INPUT element that has TYPE text.
<button>INPUT element</button>Modify the extent of the text range by moving its start and end positions with methods such as move, moveToElementText, and findText. Within the text range, you can retrieve and modify plain text or HTML text. These forms of text are identical except that HTML text includes HTML tags, and plain text does not. This object is available in script as of Microsoft?Internet Explorer
<textarea id=sel cols=80 rows=20></textarea>
</body>
</html>