Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

javascriptÖÐcreateTextRangeÓ÷¨

<script language="javascript">
function test()
{
var rng=document.body.createTextRange();
alert(rng.text)
}
function test1()
{
var rng=document.body.createTextRange();
alert(rng.htmlText)
}
</script>
<input type="button" onclick="test()" value="text">
<input type="button" onclick="test1()" value="htmlText">
»ñÈ¡Ö¸¶¨Îı¾¿òÖеÄÑ¡ÖеÄÎÄ×Ö£ºÖ»ÏìÓ¦µÚÒ»¸öÎı¾¿ò
<input id="inp1" type="text" value="1234567890">
<input id="inp2" type="text" value="9876543210">
<input type="button" onclick="test()" value="È·¶¨">
<script language="javascript">
function test()
{
var o=document.getElementById("inp1")
var r = document.selection.createRange();
if(o.createTextRange().inRange(r))
alert(r.text);
}
</script>
Ò³ÃæÎı¾µ¹Ðò²éÕÒ
abababababababa
<input value="µ¹Ðò²éÕÒa" onclick=myfindtext("a") type="button">
<script language ='javascript'>
var rng = document.body.createTextRange();
function myfindtext(text)
{
rng.collapse(false);
if(rng.findText(text,-1,1))
{
rng.select();
rng.collapse(true);
}else
{alert("end");}
}
</script>
¾Û½¹¿Ø¼þºó°Ñ¹â±ê·Åµ½×îºó
<script language="javascript"> 
function setFocus() 

var obj = event.srcElement; 
var txt =obj.createTextRange(); 
txt.moveStart('character',obj.value.length); 
txt.collapse(true); 
txt.select(); 

</script> 
<input type="text" value="http://toto369.net" onfocus="setFocus()">
µÃµ½Îı¾¿òÄÚ¹â±êλÖÃ
<script language="javascript">
function getPos(obj){
obj.focus();
var s=document.selection.createRange();
s.setEndPoint("StartToStart",obj.createTextRange())
alert(s.text.length);
}
</script>
<in


Ïà¹ØÎĵµ£º

JavaScriptÒ³ÃæË¢ÐÂÓ뵯³ö´°¿ÚÎÊÌâ½â¾ö·½·¨


1.ÎÞÌáʾˢÐÂÍøÒ³
´ó¼ÒÓÐûÓз¢ÏÖ£¬ÓÐЩÍøÒ³£¬Ë¢ÐµÄʱºò£¬»áµ¯³öÒ»¸öÌáʾ´°¿Ú£¬µã“È·¶¨”²Å»áˢС£
¶øÓеÄÒ³Ãæ²»»áÌáʾ£¬²»µ¯³öÌáʾ´°¿Ú£¬Ö±½Ó¾ÍË¢ÐÂÁË.
Èç¹ûÒ³ÃæûÓÐform£¬Ôò²»»áµ¯³öÌáʾ´°¿Ú¡£Èç¹ûÒ³ÃæÓÐform±íµ¥
a)<
form method="post" ...> »áµ¯³öÌáʾ´°¿Ú
b)< form method="get" ...& ......

javascript Ö® Closure

http://javascript.crockford.com/private.html
function a() {
var i = 0;
function b() {
alert(++i);
}
return b;
}
var c = a();
c();
 
µ±ÔÚº¯ÊýbÖзÃÎÊÒ»¸ö±äÁ¿µÄʱºò£¬ËÑË÷˳ÐòÊÇ£º
ÏÈËÑË÷×ÔÉíµÄ»î¶¯¶ÔÏó£¬Èç¹û´æÔÚÔò·µ»Ø£¬Èç¹û²»´æÔÚ½«¼ÌÐøËÑË÷º¯ÊýaµÄ»î¶¯¶ÔÏó£¬ÒÀ ......

javascript sort table & merge same column

˵Ã÷£º
appendChild()
ÎÒ²âÊԵĽá¹û£º
1 appendChild() ±í¸ñÖÐËùÓÐÐÐÑ­»·ÉÏÒÆÒ»ÐÐºó£¬ ÓÃеģ¨ÐУ©Ìæ»»ÁË ±í¸ñµÄÄ©ÐÐ £»Ï൱ÓÚÌæ»»Á˱í¸ñµÄµÚÒ»ÐУ¬²¢Ñ­»·ÉÏÒÆÒ»ÐÐ
2 ²»¸Ä±ä ±í¸ñµÄ×Ü ÐÐÊý
insertRow()
1 insertRow() ÔÚ±í¸ñÖвåÈëÒ»ÐУ¬±í¸ñ×ÜÐÐÊéÔöÒ»
2 insertRow(index) index=0 , ÔÚ±íÍ·Ôö¼Ó£¬ index=-1, ÔÚ± ......

Javascriptʼþ¼àÌý¡¾ÕûÀí¡¿

FireFox : addEventListener()·½·¨ IE : attachEvent()·½·¨ ΪHTMLÔªËØÌí¼ÓÒ»¸öʼþ¼àÌý, ¶ø²»ÊÇÖ±½Ó¶ÔÔªËصÄʼþÊôÐÔ£¨È磺onclick¡¢onmouseover£©¸³Öµ¡£ ÕâÁ½ÖÖ·½·¨´¦Àíʼþ»¹ÊÇÓкܴóÇø±ðµÄ£¡Ê¼þÊôÐÔÖ»Äܸ³ÖµÒ»ÖÖ·½·¨£¬¼´£º button1.onclick = function() { alert(1); };
button1.onclick = function() { aler ......

JavaScript Ìí¼Óɾ³ý checkbox

<html>
<body>
<table width="200" border="1" id="tb">
<tr id="r1">
<td><input type="checkbox" name="ck" value="1"></td>
<td>abc</td>
</tr>
</table>
<p>
<input type="button" onClick="add();" value="add"/> ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ