Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2007-07-20 10:54:08

jerrypena1
New member
Registered: 2007-07-20
Posts: 1
Website

How to manipulate text using javascript

I just wanted to share a couple things I figured out about how to insert (inject) text into Xinha

1) how to insert text at current position (if any text is selected it will replace it)

xinha_editors.name_of_editor.insertHTML('hello world');

2) incase you need to know what text is selected before you do anything to it use this

var my_selection = xinha_editors.name_of_editor.getSelectedHTML();

3) if you want to insert text that can also wrap a selection (such as wrapping the starting and closing a tag around a selection)

xinha_editors.name_of_editor.surroundHTML('<a href="your_link">', '</a>');


There are also text versions of these functions (I believe) in case you don't want all the HTML, but rather just the text you see in the editor.

I wish I would have known this 1 minutes after wanting to tweak Xinha.

Enjoy


Miva Merchant (eCommerce) Specialist
[url=http://www.custompartner.com/]CustomPartner.com[/url]

Offline

Board footer

Powered by FluxBB