• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

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

javascript 搞代码 7年前 (2018-06-13) 164次浏览 已收录 0个评论

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<node.childNodes.length; x++) {      var child = node.childNodes[x];      if ((child.nodeType == 3) &#038;&#038; (!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或其它方法

欢迎大家阅读《网页制作兼容Mozilla必须知道的知识_js,跪求各位点评,若觉得好的话请收藏本文,by 搞代码


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:网页制作兼容Mozilla必须知道的知识_js
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址