inserting text at cursor location
Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Rich Text Editor (RTE)
Forum Description: Support forum for the Web Wiz Rich Text Editor (RTE).
URL: https://forums.webwiz.net/forum_posts.asp?TID=23139
Printed Date: 29 March 2026 at 2:54pm Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: inserting text at cursor location
Posted By: cakewalkr7
Subject: inserting text at cursor location
Date Posted: 18 April 2007 at 6:48pm
|
One of our developers used the RTE editor a couple of years ago for our online software. He inserted a drop down box into the menu bar and when someone selected an option from the drop down, it copied it's value and pasted it where the cursor was in the RTE. We are having more and more customers using netscape browsers which kills this functionality. Does anyone know if there's a way to insert text at the cursor location without using the copy/paste functions of the browser? Thanks.
|
Replies:
Posted By: MrMellie
Date Posted: 19 April 2007 at 1:36pm
|
Yes it's possible. I've recoded my WWF forum to do that in the reply boxes for non-WSYWIG mode. It takes a bit of work to cover all the browser types as they don't all support the same document model. But it can be done. Google has lots of examples on this.
|
Posted By: cakewalkr7
Date Posted: 19 April 2007 at 8:28pm
Thanks. I've been searching for most of the day for a way to do this and can't figure it out. Do you have any code you could share? I found this, but I can't get it to work (in firefox that is).
function insertAtCursor(myField, myValue) { //IE support if (document.selection) { myField.focus(); sel = document.selection.createRange(); sel.text = myValue; } //MOZILLA/NETSCAPE support else if (myField.selectionStart || myField.selectionStart == '0') { alert('moz'); var startPos = myField.selectionStart; var endPos = myField.selectionEnd; myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length); } else { myField.value += myValue; } }
|
Posted By: cakewalkr7
Date Posted: 23 April 2007 at 1:28pm
|
Can anyone else please offer an idea on how to do this? Thank you!
|
Posted By: WebWiz-Bruce
Date Posted: 23 April 2007 at 1:35pm
The latest version of the Web Wiz RTE already has a file called RTE_javascript_gecko.asp which contains javascript for inserting various objects, text, etc. into the caret location in Netscape/Gekco based browsers.
If you have a look in allot of the files it calls this function when using these browsers so you shoudl be able to see how it works.
------------- https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting
|
Posted By: cakewalkr7
Date Posted: 23 April 2007 at 3:59pm
|
Thank you very much. I'll take a look at that.
|
|