HTML едитор

Еве брз начин како да направите сопствен html едитор. Во записот се вклучени кодот од javascript-от и html-то. Едиторот е наједноставен што може, но со малку Google-ње може да ги вклучите сите карактеристики што ги сакате.

//iframe ID
var iView = "iView";
//textarea ID
var tArea = "textarea";
var HTMLeditor = {
	content: null,
	doc: null,
	Init: function() {
		content = document.getElementById("textarea").value;
		doc = document.getElementById("iView").contentWindow.document;
		// Zapisi go tekstot od textarea-ta
		doc.open();
		doc.write(content);
		doc.close();

		doc.body.contentEditable = true;
		doc.designMode = "on";
	},
	formatIt: function(format) {
		doc.execCommand(format, false, null);
		this.focusE();
	},
	focusE: function() {
		document.getElementById(iView).contentWindow.focus();
	},
	insertUrl: function() {
		var url = prompt('Внеси URL', 'http://');
		doc.execCommand('CreateLink', false, url)
	}
}
window.onload = HTMLeditor.Init;





Демо:

Bold Italic Underline Left Center Right Full


Hits for this post:608

Leave a Comment