Home > Web Front-end > JS Tutorial > body text

Randomly display js code of personalized signature (compatible with IE, Firefox)_Other special effects

WBOY
Release: 2016-05-16 18:07:54
Original
1100 people have browsed it

The original web page uses innerText, but Script Home has replaced it with innerHTML in order to simply support firefox, because firefox does not support innerText, but there is a way to make firefox support innerText. The compatibility code is as follows.

Copy code The code is as follows:

//Let Mozilla support innerText
try{
HTMLElement.prototype.__defineGetter__
(
"innerText",
function ()
{
var anyString = "";

var childS = this.childNodes;
for(var i=0; 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){}

The following code is implemented using innerHTML. For more places, you can test it by yourself Due to time constraints, I won’t say more.

[Ctrl A select all Note: If you need to introduce external Js, you need to refresh to execute
]
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!