Skip to main content
Participating Frequently
June 20, 2009
Answered

cftextarea with script tags

  • June 20, 2009
  • 2 replies
  • 1885 views

I posted this question on the FCKeditor forum and got no reply. Hoping someone here in the CFusion forum may have insight!

We have used the FCKeditor in our CMS for years and now that CF 8 includes this as its rich text editor, we are using the version that came with CF 8 (v2.5 build 17352) instead of a separate instance.

We are having problems when including any script tags within the text area.

After content is saved to the dbase and the page reloads, the editor is no longer visible and the content that *should* display within the editor area displays at the top of the page.

Also, when content is saved, all special character encoding (e.g., ™) is lost and is replaced with question marks.

We did not have this same problem using previous versions of FCKeditor.

Is there a setting we have incorrect? Or does FCKeditor not support script tags within the cftextarea?

Thanks in advance for insight!

jLynn

    This topic has been closed for replies.
    Correct answer mack_

    Sorry in advance for so many posts trying to resolve this issue - I have spent the last two days trying to work through it an am really no closer to a solution.

    I'm not an advanced CF or Javascript programmer - self-taught and learning as I go.

    We need to launch a site soon - the site will make use of jquery in some instances and the client will need to add the appropriate script tags in the site articles.

    I would be willing to pay for a solution to this problem - recommendations for a freelance board where I can post this project and get quick response?

    TIA

    jLynn


    Use XmlFormat when sending the value to cftextarea :

    
    ]]>

    Mack

    2 replies

    Lynn_WoitAuthor
    Participating Frequently
    June 23, 2009

    Lots of view - no answers

    OK, so I've asked at the FCKeditor forum with no help and now at the Adobe forum and no help... where to turn to next???

    Suggestions?

    Inspiring
    June 23, 2009

    Lynn,

    Have you used or are you using the onComplete method of the RTE object to include your script tags?

    ColdFusion.RichText.onComplete(editorInstance)

    Here's an excerpt from the CF 8.0.1 release notes:

    The rich text editor now lets you define a ColdFusion.RichText.onComplete(editorInstance) function. When a rich text editor instance completes initializing, ColdFusion calls this function and passes it the FCKEditor instance

    that underlies the rich text editor. The function can then perform any needed post-initialization operations. The following simple example shows how you can use this function:

    <html>

    <head>

    <script type="text/javascript">

    //User defines this function to get control once the rich text editor

    //is done with its initialization

    ColdFusion.RichText.OnComplete = function(editorInstance)

    {

    alert("on complete called");

    alert("editor instance = " + editorInstance));

    }

    </script>

    </head>

    <body>

    <cfform>

    <cftextarea richtext = true name="richtext1">

    </cfform>

    </body>

    It might be the location in which you want to add the scripts (let the RTE initialize and then add your scripts). Just a thought ...

    Lynn_WoitAuthor
    Participating Frequently
    June 23, 2009

    Thanks for the reply Craig!

    Of note: Firebug tells me the error is an 'unterminated string literal'

    Following is what ColdFusion automatically generates in the head portion of the document when rendering the page. Looks like the error is in the intialization but I can't see what the error is.

    <script type="text/javascript">

    _cf_richtext_init_1245775594721=function()

    {

    ColdFusion.RichText.initialize('cf_textarea1245775594720', 'body', '<script type="text/javascript"><br> alert("hello world");<br></script>

    ', '/CFIDE/scripts/ajax/FCKeditor/', null, 400, null, null, null, null, false, 'articleBody', null, null, 'en');

    };ColdFusion.Event.registerOnLoad(_cf_richtext_init_1245775594721);

    </script>

    ===================

    And this is the form generated:

    <form name="articleEdit" id="articleEdit" action="index.cfm?" method="post" onsubmit="return _CF_checkarticleEdit(this)">

    <textarea name="body"  id="cf_textarea1245775594720" cols="100" rows="5" ><script type="text/javascript">

    alert("hello world");

    </script>

    </textarea>

    </form>

    ===============

    Lynn_WoitAuthor
    Participating Frequently
    June 22, 2009

    So, am I the only one who is having a problem when using script tags in the FCKeditor enabled cftextarea?

    We are getting ready to launch a site that makes use of jquery image galleries and modal windows and I need for our client to be able to edit these.

    I can deal with the client having to edit the html instead of the rich text.

    What I can't deal with is the special characters (™, ®, etc) being trashed when saved to the mySQL database.

    It's curious that Adobe uses tiny_mce3 instead of FCKeditor for this forum. It actually looks like it might be a better editor.

    Again, TIA for any insight!

    jLynn