<div class="htmlarea"> <textarea id="runcode23157"> <title> new document </title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <div id="msg"></div> <input id="txt" value=""> <input id="btn" value="dsa" type="button" onclick="ff()"> <script> //当状态改变的时候执行的函数 function handle() { document.getElementById('msg').innerHTML = "输入的文字为:" + document.getElementById('txt').value; } if(/msie/i.test(navigator.userAgent)) //ie浏览器 { document.getElementById('txt').onpropertychange = handle; } else {//非ie浏览器,比如Firefox document.getElementById('txt').addEventListener("input", handle, false); document.getElementById('txt').watch('a', fn); } function ff() { document.getElementById('txt').value=Math.random(); } </script> </textarea><br><input onclick="runEx('runcode23157')" type="button" value="运行代码"> <input onclick="doCopy('runcode23157')" type="button" value="复制代码"> <input onclick="doSave(runcode23157)" type="button" value="保存代码">[Ctrl+A 全选 注:<a href="http://www.jb51.net/article/23421.htm" title="查看具体详情" target="_blank">如需引入外部Js需刷新才能执行</a>]</div>