javascript - the w3c Statement generate an error~can you help me? -
the first written
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <textarea rows="7" cols="49" id="box" onclick=tellpoint()></textarea> <script language="javascript"> function tellpoint() { var rng = event.srcelement.createtextrange(); rng.movetopoint(event.x,event.y); rng.movestart("character",-event.srcelement.value.length); pnum.value = rng.text.length; } </script> <p></p> position:<input type="text" value="0" id="pnum" size="8">
it wrong in ie8.0 browser
however,the sec written
<textarea rows="7" cols="49" id="box" onclick=tellpoint()></textarea> <script language="javascript"> function tellpoint() { var rng = event.srcelement.createtextrange(); rng.movetopoint(event.x,event.y); rng.movestart("character",-event.srcelement.value.length); pnum.value = rng.text.length; } </script> <p></p> 光标位置:<input type="text" value="0" id="pnum" size="8">
it right.
i have no idea,how can can create first work well?thanks~
javascript jquery
No comments:
Post a Comment