Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - inserting text at cursor location
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Forum Lockedinserting text at cursor location

 Post Reply Post Reply
Author
cakewalkr7 View Drop Down
Newbie
Newbie


Joined: 18 April 2007
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote cakewalkr7 Quote  Post ReplyReply Direct Link To This Post Topic: inserting text at cursor location
    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.
Back to Top
MrMellie View Drop Down
Senior Member
Senior Member
Avatar

Joined: 12 December 2006
Location: United Kingdom
Status: Offline
Points: 251
Post Options Post Options   Thanks (0) Thanks(0)   Quote MrMellie Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
cakewalkr7 View Drop Down
Newbie
Newbie


Joined: 18 April 2007
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote cakewalkr7 Quote  Post ReplyReply Direct Link To This Post 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;
      }
}


Edited by cakewalkr7 - 19 April 2007 at 8:28pm
Back to Top
cakewalkr7 View Drop Down
Newbie
Newbie


Joined: 18 April 2007
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote cakewalkr7 Quote  Post ReplyReply Direct Link To This Post Posted: 23 April 2007 at 1:28pm
Can anyone else please offer an idea on how to do this?  Thank you!
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post 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.


Edited by -boRg- - 23 April 2007 at 1:36pm
Back to Top
cakewalkr7 View Drop Down
Newbie
Newbie


Joined: 18 April 2007
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote cakewalkr7 Quote  Post ReplyReply Direct Link To This Post Posted: 23 April 2007 at 3:59pm
Thank you very much.  I'll take a look at that.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.