繁体中文
设为首页
加入收藏
当前位置:网站制作首页 >> JavaScript教程 >> 网页制作兼容Mozilla必须知道的知识

网页制作兼容Mozilla必须知道的知识

2007-05-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:IE Mozilla 说明 document.all(id) document.getElementById(id) 无 document.all document.getElementsByTagName("*") 无 document.body.clientHeight(clientWidth)根据HTML的DTD而定方能得到准确值。 window.i...

IE

Mozilla

说明

document.all(id)

document.getElementById(id)

document.all

document.getElementsByTagName("*")

document.body.clientHeight(clientWidth)根据HTML的DTD而定方能得到准确值。

window.innerHeight(innerWidth)根据HTML的DTD而定方能得到准确值。

opacity(aplha=20)

MozOpacity="0.2"

可参看我的blog这篇文章

event.clientY(clientX)

event.pageY(pageX)

event.keyCode

event.which

event.srcElement

event.target

window.external.AddFavorite('never-online.net', "never-online'website");

window.sidebar.addPanel('never-online.net', "never-online'website", "");

event.clientY(clientX)

event.pageY(pageX)

(DHTML事件-滚轮事件)onmousewheel

DOMMouseScroll

可参看我的blog这篇文章

window.showModalDialog

window.open(url, "name", "modal=yes")

createPopup()

xul

htc控件

xbl绑定

filter滤镜

只支持alpha(透明度,部分可通过clip来模拟)

obj.setCapture()

window.captureEvents(Event.eventType)

obj.attachEvent(type, listener)

obj.addEventListener(type, listener, useCapture)

obj.detachEvent(type, listener)

obj.removeEventListener(type, listener, useCapture)

脚本预解释执行

o={

foo: function(){

alert("never-online");

}

};

with (o) {

bar();

function bar(){

alert("never-online");

}

foo();

}

上面的代码成功输出never-online

脚本顺序执行。

o={

foo: function(){

alert("never-online");

}

};

with (o) {

bar();

function bar(){

alert("never-online");

}

foo();

}

报错bar未定义

解决方法有很多种,请参见我这里的评论或者这篇文章

支持Webdings字体

不支持Webdings字体

insertAdjacentHTML, insertAdjacentElement方法

本身不支持,但可通过insertBefore或通过Range实现

可参见我这篇文章的代码

不支持

读写器__defineSetter(Getter)__

不支持

支持对Element,EVENT等对象的prototype模式支持

不支持

对节点有nodeType常量属性

new ActiveXObject("MSXML2.XMLHTTP")或更高版本的ProgId

XMLHttpRequest对象

设置类似style.top=20这样的高度时,可不使用单位

设置类似style.top=20+'px'这样的高度时,必须使用单位,否则无效

CSS的类名,不区分大小写(大小写不敏感)

CSS的类名,区分大小写(大小写敏感)如:.myCss和.mycss类名就是不相同的

冒泡事件event.cancelBubble=true

event.stopPropagation()(需要传递event事件)

parentElement

默认不支持,但可以利用Mozilla特性模拟

HTMLElement.prototype.__defineGetter__("parentElement",

function () {

if (this.parentNode == this.ownerDocument) return null;

return this.parentNode;

});

无空白节点

因为Mozilla下NodeType下定义有12种节点属性,所以要去除空白的节点方能得到预期值

var notspace = /\S/;

function cleanWhitespace(node) {

for (var x=0; x

var child = node.childNodes[x];

if ((child.nodeType == 3) && (!notspace.test(child.nodeValue))) {

node.removeChild(node.childNodes[x]); x--;

}; if(child.nodeType == 1) { cleanWhitespace(child); }

}

}

CSS padding宽度并不在offset偏移坐标之内

CSS padding宽度默认是在offset偏移坐标之内,可用-moz-box-sizing:border-box来设置即可基本与IE相同

可参见我这篇文章的代码

js动态加载xslt文件将xml转化成HTML,IE可用xmldoc.transformNode(xslDocument)方法

Mozilla中相对麻烦一些,要经过几道工序XSLTProcessor对象,transformToFragment或其它方法

责任编辑:admin
相关文章