var ie4=document.all&&navigator.userAgent.indexOf("Opera")==-1 |
var ns6=document.getElementById&&!document.all |
var ns4=document.layers |
设 e 为 NS 浏览器事件过程第一个参数。
属性(IE) | 属性(NS) | NS4 | 描述 |
---|---|---|---|
altKey | modifiers | 如果按下了 Alt 键,则返回TRUE | |
ctrlKey | modifiers | 如果按下了Ctrl键,则返回TRUE | |
shiftKey | modifiers | 如果Shift键按下,则返回TRUE | |
keyCode | e.which | 返回所按键的Unicode。适用于onkeydown、onkeyup和onkeypress事件 | |
screenX | screenX | 返回鼠标相对于屏幕的坐标 x | |
screenY | screenY | 返回鼠标相对于屏幕的坐标 y | |
clientX | pageX e.clientX | e.x | 返回鼠标相对于窗口的坐标 x |
clientY | pageY e.clientY | e.y | 返回鼠标相对于窗口的坐标 y |
x | x | 与 clientX 差不多。 | |
y | y | 与 clientY 差不多。 | |
srcElement | e.target | 返回发生事件的对象 |
(IE) | (NS) |
---|---|
document.onclick = abc ;
function abc { ...; } |
document.onclick = abc;
document.captureOnClick(Event.ONCLICK); function abc(e) { ...; } |
(IE) | (NS4) | (NS6) |
---|---|---|
document.all.idname
document.getElementById("id") document.getElementsByName("name") document.getElementsByTagName("tagname") document.all["idname"] |
document.idname | document.idname
document.getElementById("id") |
项目 | (NS) | (IE) |
---|---|---|
新增 option | select.options[select.options.length] = new Option("text",val); |
select.options[select.options.length] = new Option("text",val); select.add(new Option("text", val); |
删除 option | Select.options[i] = null; | Select.options[i] = null;
Select.options.remove(i); |
项目 | (NS) | (IE) |
---|---|---|
居中 | <center></center> | <center></center>
<p align=center></p> |
class | 区分大小写 | 不区分大小写 |
父/子对象 | ParentNode
ChildNodes |
parentNode / ParentElement
childNodes / Children |
访问表单 | document.form | document.form
window.form |
元素引用 | document.form_name.element_name
document.form_name.element_name[i] document.form_name.elements[element_name] |
form_name.element_name
form_name.all(element_name) form_name.elements(element_name) element_id |
radio 多选 | 放入 <form></form> | |
自定义属性 | obj.attributes.getNamedItem("attrname").value | obj.attrname |
设置对象位置 | 读取时用:obj.offsetLeft
设置时用: obj.style.left |