Click here to Skip to main content
15,893,814 members
Articles / Web Development / XHTML

Integrating FCKeditor in ASP.NET

Rate me:
Please Sign up or sign in to vote.
4.43/5 (15 votes)
20 Jul 2008CPOL2 min read 270.1K   10.1K   64  
Integrating FCKeditor in ASP.NET
/*
	 * FCKeditor - The text editor for internet
	 * Copyright (C) 2003-2006 Frederico Caldeira Knabben
	 *
	 * Licensed under the terms of the GNU Lesser General Public License:
	 *              http://www.opensource.org/licenses/lgpl-license.php
	 *
	 * For further information visit:
	 *              http://www.fckeditor.net/
	 *
	 * "Support Open Source software. What about a donation today?"
	 *
	 * File Name: fckeditorapi.js
	 *      Create the FCKeditorAPI object that is available as a global object in
	 *      the page where the editor is placed in.
	 *
	 * File Authors:
	 *              Frederico Caldeira Knabben (fredck@fckeditor.net)
	 */
	
	var FCKeditorAPI ;
	
	function InitializeAPI()
	{
	        if ( !( FCKeditorAPI = window.parent.FCKeditorAPI ) )
	        {
	                // Make the FCKeditorAPI object available in the parent window. Use
	                // eval so it is independent from this window and so it will still be
	                // available if the editor instance is removed ("Can't execute code
	                // from a freed script" error).
	                var sScript = '\
	                        var FCKeditorAPI = {\
	                                Version                 : \'2.3.2\',\
	                                VersionBuild    : \'1082\',\
	                                __Instances             : new Object(),\
	                                GetInstance             : function( instanceName )\
	                                {\
	                                        return this.__Instances[ instanceName ] ;\
	                                },\
	                                _FunctionQueue  : {\
	                                        Functions       : new Array(),\
	                                        IsRunning       : false,\
	                                        Add                     : function( functionToAdd )\
	                                        {\
	                                                this.Functions.push( functionToAdd ) ;\
	                                                if ( !this.IsRunning )\
	                                                        this.StartNext() ;\
	                                        },\
	                                        StartNext       : function()\
	                                        {\
	                                                var aQueue = this.Functions ;\
	                                                if ( aQueue.length > 0 )\
	                                                {\
	                                                        this.IsRunning = true ;\
	                                                        aQueue[0].call() ;\
	                                                }\
	                                                else\
	                                                        this.IsRunning = false ;\
	                                        },\
	                                        Remove          : function( func )\
	                                        {\
	                                                var aQueue = this.Functions ;\
	                                                var i = 0, fFunc ;\
	                                                while( fFunc = aQueue[ i ] )\
	                                                {\
	                                                        if ( fFunc == func )\
	                                                                aQueue.splice( i,1 ) ;\
	                                                        i++ ;\
	                                                }\
	                                                this.StartNext() ;\
	                                        }\
	                                }\
	                        }' ;
	               
	                // In IE, the "eval" function is not always available (it works with
	                // the JavaScript samples, but not with the ASP ones, for example).
	                // So, let's use the execScript instead.
	                if ( window.parent.execScript )
	                        window.parent.execScript( sScript, 'JavaScript' ) ;
	                else
	                {
	                        if ( FCKBrowserInfo.IsGecko10 )
	                        {
	                                // FF 1.0.4 gives an error with the above request. The
	                                // following seams to work well. It could become to official
	                                // implementation for all browsers, but we need to check it.
	                                eval.call( window.parent, sScript ) ;
	                        }
	                        else
	                                window.parent.eval( sScript ) ;
	                }
	               
	                FCKeditorAPI = window.parent.FCKeditorAPI ;
	        }
	
	        // Add the current instance to the FCKeditorAPI's instances collection.
	        FCKeditorAPI.__Instances[ FCK.Name ] = FCK ;
	}
	
	function FCKeditorAPI_Cleanup()
	{
	        FCKeditorAPI.__Instances[ FCK.Name ] = null ;
	}
	//FCKTools.AddEventListener( window, 'unload', FCKeditorAPI_Cleanup ) ;   

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
Bangladesh Bangladesh
Software Engineer, Bangladesh.

Comments and Discussions