首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

使红狐支持outHTML

2012-10-11 
使火狐支持outHTMLif (typeof (HTMLElement) ! undefined && !window.opera) {HTMLElement.prototype._

使火狐支持outHTML

if (typeof (HTMLElement) != "undefined" && !window.opera) {HTMLElement.prototype.__defineGetter__("outerHTML", function() {var a = this.attributes, str = "<" + this.tagName, i = 0;for (; i < a.length; i++)if (a[i].specified)str += " " + a[i].name + '="' + a[i].value + '"';if (!this.canHaveChildren)return str + " />";return str + ">" + this.innerHTML + "</" + this.tagName + ">";});HTMLElement.prototype.__defineSetter__("outerHTML", function(s) {var r = this.ownerDocument.createRange();r.setStartBefore(this);var df = r.createContextualFragment(s);this.parentNode.replaceChild(df, this);return s;});HTMLElement.prototype.__defineGetter__("canHaveChildren",function() {return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase());});} 

热点排行