Jump to content

Recommended Posts

I would like to add smileys to my blog - but keep it basic basic very basic. Pretty much a simple textarea with the option to add a smiley here and a smiley there. Trick is, I would like the smileys to be added at the cursor's location and even replace text if it's highlighted. - Just like it's done on phpfreaks, but I don't want all the other fancy tags (bold, italics, pictures, font size or face, etc)...

 

Maybe someone knows of a good tutorial or someone can lead me to the right direction. Google hasn't been very helpful.

Perhaps this could be helpful to you:

 

http://www.almsamim.com/create-your-own-advanced-wysiwyg-editor-part-1-t10.html

 

I've not read it myself but the comments seem positive. I dare say in order to create your own custom 'basic' editor, you're probably going to have to learn some of the advanced stuff as well.

I finally got it to work. I just needed some javascript to add "text" smileys at the cursor point.

 

	// Add symbol to textarea
		// Cache textarea
		textarea = document.getElementById('textboxer');

		// IE support
		if (document.selection) {
			textarea.focus();
			sel = document.selection.createRange();
			sel.text = symbol;
		}
		//MOZILLA/NETSCAPE support
		else if (textarea.selectionStart || textarea.selectionStart == '0') {
			textarea.focus();
			var startPos = textarea.selectionStart;
			var endPos = textarea.selectionEnd;
			textarea.value = textarea.value.substring(0, startPos) + symbol + textarea.value.substring(endPos, textarea.value.length);
		}
		// Default to appending the smiley at the end
		else {
			textarea.value += symbol;
		}

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.