faqts : Computers : Programming : Languages : JavaScript : DHTML

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

140 of 189 people (74%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

How do I emulate innerText in mozilla/gecko/NS6+ ?

May 26th, 2005 06:13
Marius Strumyla, Thor Larholm,


if(typeof HTMLElement!="undefined"){
	HTMLElement.prototype.innerText getter = function(){
		var tmp = this.innerHTML.replace(/<br>/gi,"\n");
		return tmp.replace(/<[^>]+>/g,"");
	}
	HTMLElement.prototype.innerText setter = function(txtStr){
		var parsedText = document.createTextNode(txtStr);
		this.innerHTML = "";
		this.appendChild( parsedText );
	}
}