Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Using Javascript to add text to rich text editor textboxUsing Javascript to add text to rich text editor textbox
Previous
 
Next
New Post
2/12/2011 2:37 PM
 
Hello,
I would like to make a link that injects pre-defined text into a rich text textbox/texarea. 

In other words, I want to use it links like a "text expander" to add some pre-defined links to a form and list module rich text box... and this form serves as a message body for e-mail to send out to people.  

I got the Javascript to work with an HTML text area.  I assume I use the id of the text area for the Rich Text box to "inject" some text into the text area.







For example:

<a href="#" onclick="addLink('Technical Support','http://www.mysite.com/Support.aspx','DESCRIPTION: Visit our support page for more information, live chat, and support numbers','textfield'); return false;">Technical Support </a>

When people click on the "Technical Support" link above within an HTML module, it works if the HTML module contains a textarea with id of textfield.  However, if I change the id to be dnn_ctr807_Default_Form_Message_Body_Message_BodyContentHiddenTextarea , for example, it doesn't work.  Is there a way to find the id to put the text into?

Form and List module (link can be in an HTML module above), it adds the following to the Form and List rich text box area:


TITLE: Technical Support
URL: http://www.mysite.com/Support.aspx
DESCRIPTION: Visit our support page for more information, live chat, and support numbers
-------------------------


Any thoughts?
 
New Post
2/12/2011 5:16 PM
 
Basically the problem is that the body in the IFRAME created by radeditor does not have an ID associated with it.
I may try to make the default value of RichText to be < p id="whateveriwant> and find the p
 
New Post
2/12/2011 7:17 PM
 
OK still at a loss.
Perhaps I can use jQuery to find the body tag within the RadEditor IFRAME?

http://api.jquery.com/contents/

$('iframe').ready(function() {
$("iframe").contents().find("body#tinymce").css("background-color","green");
});

Another less desirable option is using Snippets within RadEditor.
 
New Post
2/12/2011 7:56 PM
 
One other option would be to check out the dnnwerk radeditor provider - http://radeditor.codeplex.com/release... - which has recently been donated to the dnn core - (and most likely to appear as part of the core in 5.6.2)

It lets you define separate toolbar layout templates for different pages on your site - and also lets you add add custom dropdown menus which you could use to define your own blocks of inserted text.

Westa
 
New Post
2/13/2011 12:46 AM
 
Thanks Wes --
I finally figured it out...  add this to the head

<script type="text/javascript">
function addLink(linktitle, linkurl, linkdescription, radeditoriframeid) {
var iFrame = document.getElementById(radeditoriframeid);
if ( iFrame.contentDocument ) 
   { // FF
     if (linkdescription=='') {
iFrame.contentDocument.getElementsByTagName('body')[0].innerHTML += '<b>TITLE:</b> ' + linktitle + '<br /><b>URL:</b> <A HREF=' + linkurl +'>' + linkurl + '</A><br />-------------------------<br />';}
else
{iFrame.contentDocument.getElementsByTagName('body')[0].innerHTML += '<b>TITLE:</b> ' + linktitle + '<br /><b>URL:</b> <A HREF=\"' + linkurl +'\">' + linkurl + '</A><br /><B>DESCRIPTION:</B> ' + linkdescription + '<br />-------------------------<br />';}
   }
   else if ( iFrame.contentWindow ) 
   { // IE
     if (linkdescription=='') {
iFrame.contentWindow.document.getElementsByTagName('body')[0].innerHTML += '<b>TITLE:</b> ' + linktitle + '<br /><b>URL:</b> <A HREF=' + linkurl +'>' + linkurl + '</A><br />-------------------------<br />';}
else
{iFrame.contentWindow.document.getElementsByTagName('body')[0].innerHTML += '<b>TITLE:</b> ' + linktitle + '<br /><b>URL:</b> <A HREF=\"' + linkurl +'\">' + linkurl + '</A><br /><B>DESCRIPTION:</B> ' + linkdescription + '<br />-------------------------<br />';}
}

}

function ResetTextBox(radeditoriframeid, resettext) {
var iFrame = document.getElementById(radeditoriframeid);
if ( iFrame.contentDocument ) 
   { // FF
    
iFrame.contentDocument.getElementsByTagName('body')[0].innerHTML = resettext;
   }
   else if ( iFrame.contentWindow ) 
   { // IE
   iFrame.contentWindow.document.getElementsByTagName('body')[0].innerHTML = resettext;
   }
}


function AddEndToMsg(endmsg, radeditoriframeid) {
var iFrame = document.getElementById(radeditoriframeid);

if ( iFrame.contentDocument ) 
   { // FF
iFrame.contentDocument.getElementsByTagName('body')[0].innerHTML += endmsg;
}
   else if ( iFrame.contentWindow ) 
   { // IE
    
iFrame.contentWindow.document.getElementsByTagName('body')[0].innerHTML += endmsg;
}
   }

</script>
 
Previous
 
Next
HomeHomeUsing DNN Platf...Using DNN Platf...Using Modules a...Using Modules a...Using Javascript to add text to rich text editor textboxUsing Javascript to add text to rich text editor textbox


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out