1. 最常用的
2.功能强大的debug
- // JScript 文件
- /*通过html标签的id取得对象引用.
- 返回对象.
- */
- function getById(id)
- {
- return document.getElementById(id);
- }
- /*创建一个html标签.
- 返回对象.
- */
- function createObj(name)
- {
- return document.createElement(name);
- }
- <!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" >
- <head>
- <title>猴子的强大debug函数</title>
- <script type="text/javascript">
- function upperCase()
- {
- var x=document.getElementById("fname").value
- document.getElementById("fname").value=x.toUpperCase()
- alert("自动转化为大写");
- }
- function debug(o){a=[];for(k in o)a.push(k+":"+o[k]);alert(a.join("/n"))}
- document.onclick=function(e){
- ee=e||event;
- debug(e);
- }
- </script>
- </head>
- <body>
- <div>
- 输入您的姓名:
- <input type="text" id="fname" onblur="upperCase()" />
- </div>
- </body>
- </html>