当前位置:开发者网络 >> 网页特效 >> 文本特效 >> 内容
精彩推荐
分类最新特效
分类热点特效
  
神奇的文本框(在网页中选中任何字符都会在该文本框中)
日期:2005-06-07   人气:   【字体: 】【收藏此文


<!-- 网页特效代码由[中国WEB开发者网络:http://www.ChinaWebDev.com]提供! -->
<!-- 要实现此效果需要 2 个步骤: -->

<!-- 第 1 步: -->
<!-- 把下面的代码加到<HEAD></HEAD>区域中: -->


<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var text = "";
function getActiveText(e) {


text = (document.all) ? document.selection.createRange().text : document.getSelection();

document.theform.text.value = text;
return true;
}

document.onmouseup = getActiveText;
if (!document.all) document.captureEvents(Event.MOUSEUP);
// End -->
</script>



<!-- 第 2 步: -->
<!-- 把下面的代码加到<BODY></BODY>区域中: -->

<center>
<form name=theform>
被选中的文本: <input type=text name=text value="">
</form>
</center>