javascript实用的N个小例子
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://gzycm520.blog.51cto.com/175220/36822
· 事件源对象 event.srcElement.tagName event.srcElement.type
· 捕获释放 event.srcElement.setCapture(); event.srcElement.releaseCapture();
· 事件按键 event.keyCode event.shiftKey event.altKey event.ctrlKey
· 事件返回值 event.returnValue · 鼠标位置 event.x event.y
· 窗体活动元素 document.activeElement
· 绑定事件 document.captureEvents(Event.KEYDOWN);
· 访问窗体元素 document.all("txt").focus(); document.all("txt").select();
· 窗体命令 document.execCommand
· 窗体COOKIE document.cookie
· 菜单事件 document.oncontextmenu
· 创建元素 document.createElement("SPAN");
· 根据鼠标获得元素: document.elementfromPoint(event.x,event.y).tagName=="TD document.elementfromPoint(event.x,event.y).appendChild(ms)
· 窗体图片 document.images[索引]
· 窗体事件绑定 document.
· 元素 document.窗体.elements[索引]
· 对象绑定事件 document.all.xxx.detachEvent('
· 插件数目 navigator.plugins
· 取变量类型 typeof($js_libpath) == "undefined"
· 下拉框 下拉框.options[索引] 下拉框.options.length
· 查找对象 document.getElementsByName("r1"); document.getElementById(id);
· 定时 timer=setInterval('scrollwindow()',delay); clearInterval(timer);
· UNCODE编码 escape() ,unescape
· 父对象 obj.parentElement(dhtml) obj.parentNode(dom)
· 交换表的行 TableID.moveRow(2,1)
· 替换CSS document.all.csss.href = "a.css";
· 并排显示 display:inline
· 隐藏焦点 hidefocus=true
· 根据宽度换行 style="word-break:break-all"
· 自动刷新 <meta HTTP-EQUIV="refresh" CONTENT
相关文档:
对象初始化方式(也叫json对象创建方式)
<script type="text/javascript">
var User = {
name:"centerqi",
age:25,
toString:function()
  ......
<!doctype html>
<html lang="zh-ch">
<head>
<meta charset="utf-8" />
<meta content="IE=8" http-equiv="X-UA-Compatible"/>
<title>mousewheel的事件绑定 by 司徒正美</title>
<mce:script type="text/javascript"><!--
window. ......
1. 让文字不停的滚动。
<marouee>滚动文字</marouee>
2.记录并显示网页的最后修改时间
<script language="javascript">
doucument.write("最后更新时间:" + document.lastModified + " " ......
我想使用过ajax的都常见这样的代码:
<a href="javascript:doTest2();void(0);">here</a>
但这儿的void(0)究竟是何含义呢?
Javascript中void是一个操作符,该操作符指定要计算一个表达式但是不返回值。
void 操作符用法格式如下:
1. javascript:void (expression)
2. javascript:void expression
expr ......
IE event.keyCode
keycode 8 = BackSpace BackSpace
keycode 9 = Tab Tab
keycode 12 = Clear
keycode 13 = Enter
keycode &nb ......