`

FF下面实现outerHTML

 
阅读更多

http://w3help.org/zh-cn/causes/SD9017 w3help给了相对详细的解释;

http://msdn.microsoft.com/en-us/library/ms534310(v=VS.85).aspx    MSDN中对outerHTMl的解释

 

<SCRIPT LANGUAGE=”JavaScript”>
<!–
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 d = document.createElement(”DIV”); d.innerHTML = s;
for(var i=0; i<d.childNodes.length; i++)
this.parentNode.insertBefore(d.childNodes[i], this);
this.parentNode.removeChild(this);
});
HTMLElement.prototype.__defineGetter__(”canHaveChildren”,function()
{
return !/^(area|base|basefont|col|frame|hr|img|br|input|isindex|link|meta|param)$/.test(this.tagName.toLowerCase());
});
}
//–>
</SCRIPT>

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics