当前位置:主页 > 网页前端 > JavaScript代码 >

随机显示个性签名的js代码(兼容ie,firefox)

时间:2021-01-28 10:22:49 | 栏目:JavaScript代码 | 点击:

复制代码 代码如下:

//让Mozilla支持innerText
try{
HTMLElement.prototype.__defineGetter__
(
"innerText",
function ()
{
var anyString = "";

var childS = this.childNodes;
for(var i=0; i<childS.length; i++)
{
if(childS[i].nodeType==1)
anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
else if(childS[i].nodeType==3)
anyString += childS[i].nodeValue;
}
return anyString;
}
);
}
catch(e){}

以下使用innerHTML实现的代码,其它更多的地方,大家自行测试因时间关系,不多说了。

[Ctrl+A 全选 注:引入外部Js需再刷新一下页面才能执行]

您可能感兴趣的文章:

相关文章