关于FCKeditor,在一个新建的PHP文件里,如何才可以使用一些FCK的JS函数<script type="text/javascript" src="../../fckconfig.js"></script>
<script type="text/javascript" src="../js/fck_startup.js"></script>
<script type="text/javascript" src="common/fck_dialog_common.js"></script>
<script>
function insertpic(url){
    var oEditor = FCKeditorAPI.GetInstance('CONTENT');
    oEditor.InsertHtml(url);
}
</script>
oEditor.InsertHtml(url);   错误提示  undefined  或者 无对象。。

解决方案 »

  1.   

    让你去debug,你又不debug,你再发问不还是一样的情况!另外你可以把你的FCKeditor的版本发出来,或者把你的FCKeditor打包一下,让别人想帮你也能有入手的地方!就你说个错误现象,怎么给你提供帮助!你把你的代码全贴出来也算!fck_startup.js 不能正确加载 FCKeditorAPI未定义页面没有CONTENT这个编辑器框,也会出现 未定义你让人猜吗。
      

  2.   

    哦。谢谢你
    引入路径是没错的,不会用DEGUG呢
    版本也不懂哪里查看,呜
    我在fckeditorcode_ie_2.js里直接用
    var oEditor = FCKeditorAPI.GetInstance('CONTENT');
    oEditor.InsertHtml(url);
    是可以的
    贴代码不懂贴哪些,打包不懂打包哪些
      

  3.   

    文件搜索过,是没有ID等于CONTENT的编辑框,但上面那个又可以用,好奇怪
      

  4.   

    FCKeditorAPI.GetInstance('CONTENT');这个 CONTENT 是表单中的一个文本框
    是用来作为 FCKeditor 与表单的接口,否则你不可能提交 FCKeditor 中的数据
      

  5.   

    undefined 为空或不是对象。
    经测试,fck_startup.js 已加载 
      

  6.   


    我在fckeditorcode_ie_2.js里直接用
    var oEditor = FCKeditorAPI.GetInstance('CONTENT');
    oEditor.InsertHtml(url); 是可以向编辑框插入内容的只有这个文件出现过 'CONTENT'<?php 
    /* * 
     * File Name: sample01.php
     *  Sample page.
     * 
     */include("../../fckeditor.php") ;
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title>FCKeditor - Sample</title>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <meta name="robots" content="noindex, nofollow">
    <link href="../sample.css" rel="stylesheet" type="text/css" />
    </head>
    <body>

    <form action="sampleposteddata.php" method="post" target="_blank">
    <?php
    // Automatically calculates the editor base path based on the _samples directory.
    // This is usefull only for these samples. A real application should use something like this:
    // $oFCKeditor->BasePath = '/FCKeditor/' ; // '/FCKeditor/' is the default value.
    $sBasePath = $_SERVER['PHP_SELF'] ;
    $sBasePath = substr( $sBasePath, 0, strpos( $sBasePath, "_samples" ) ) ;$oFCKeditor = new FCKeditor('CONTENT') ;
    $oFCKeditor->BasePath = $sBasePath ;
    $oFCKeditor->Value = '这里是内容编辑区域.' ;
    $oFCKeditor->Create() ;
    ?>

    <input type="submit" value="Submit">
    </form>
    </body>
    </html>
      

  7.   


    看看什么地方引用了fckeditorcode_ie_2.js这个文件。关键字 <script  和 fckeditorcode_ie_2.js
    然后去引用的地方看看,CONTENT的框再哪里,然后把那个框放到你的新的文件中!
      

  8.   

    fckeditorcode_ie_1.js 引用了 fckeditorcode_ie_2.js   
    fck_startup.js 中 FCKScriptLoader.AddScript('js/fckeditorcode_ie_1.js');
    不知道哪里有CONTENT的框FCKeditorAPI.Version='2.1.1'; 这话是 版本吗  
      

  9.   

    我不明白你要JS函数做什么呢???直接调用 fck 编辑器就好了,里面什么东西都有。我觉得LZ没有把你想要的东西表达清楚。。你到底想做什么?有什么目的?这么做为了什么?
      

  10.   

    是这样的,我新加了一个按钮,按钮打开一个窗口,左边是列表,右边是相应数据库的数据
    最后一步就是点击该数据 然后把内容插入到编辑框里去所以想用 InsertHtml()这个函数  
      

  11.   

    这个是类似的,其中就是用了FCK.InsertHtml( FCK._Templates[index].Html ) ;
    我相似的用了 
    var oEditor = window.parent.InnerDialogLoaded() ;
    var FCK = oEditor.FCK ;
    FCK.InsertHtml(url);
    也还是不行<script src="common/fck_dialog_common.js" type="text/javascript"></script>
    <script language="javascript">var oEditor = window.parent.InnerDialogLoaded() ;
    var FCK = oEditor.FCK ;
    var FCKLang = oEditor.FCKLang ;
    var FCKConfig = oEditor.FCKConfig ;window.onload = function()
    {
    // Set the right box height (browser dependent).
    GetE('eList').style.height = document.all ? '100%' : '295px' ; // Translate the dialog box texts.
    oEditor.FCKLanguageManager.TranslatePage(document) ; window.parent.SetAutoSize( true ) ; LoadTemplatesXml() ;
    }function LoadTemplatesXml()
    {
    if ( !FCK._Templates )
    {
    GetE('eLoading').style.display = '' ; // Create the Templates array.
    FCK._Templates = new Array() ; // Load the XML file.
    var oXml = new oEditor.FCKXml() ;
    oXml.LoadUrl( FCKConfig.TemplatesXmlPath ) ; // Get the Images Base Path.
    var oAtt = oXml.SelectSingleNode( 'Templates/@imagesBasePath' ) ;
    var sImagesBasePath = oAtt ? oAtt.value : '' ; // Get the "Template" nodes defined in the XML file.
    var aTplNodes = oXml.SelectNodes( 'Templates/Template' ) ; for ( var i = 0 ; i < aTplNodes.length ; i++ )
    {
    var oNode = aTplNodes[i] var oTemplate = new Object() ; var oPart ; // Get the Template Title.
    if ( oPart = oNode.attributes.getNamedItem('title') )
    oTemplate.Title = oPart.value ;
    else
    oTemplate.Title = 'Template ' + ( i + 1 ) ; // Get the Template Description.
    if ( oPart = oXml.SelectSingleNode( 'Description', oNode ) )
    oTemplate.Description = oPart.text ? oPart.text : oPart.textContent ; // Get the Template Image.
    if ( oPart = oNode.attributes.getNamedItem('image') )
    oTemplate.Image = sImagesBasePath + oPart.value ; // Get the Template HTML.
    if ( oPart = oXml.SelectSingleNode( 'Html', oNode ) )
    oTemplate.Html = oPart.text ? oPart.text : oPart.textContent ;
    else
    {
    alert( 'No HTML defined for template index ' + i + '. Please review the "' + FCKConfig.TemplatesXmlPath + '" file.' ) ;
    continue ;
    } FCK._Templates[ FCK._Templates.length ] = oTemplate ;
    } GetE('eLoading').style.display = 'none' ;
    } if ( FCK._Templates.length == 0 )
    GetE('eEmpty').style.display = '' ;
    else
    {
    for ( var i = 0 ; i < FCK._Templates.length ; i++ )
    {
    var oTemplate = FCK._Templates[i] ; var oItemDiv = GetE('eList').appendChild( document.createElement( 'DIV' ) ) ;
    oItemDiv.TplIndex = i ;
    oItemDiv.className = 'TplItem' ; // Build the inner HTML of our new item DIV.
    var sInner = '<table><tr>' ; if ( oTemplate.Image )
    sInner += '<td valign="top"><img src="' + oTemplate.Image + '"><\/td>' ; sInner += '<td valign="top"><div class="TplTitle">' + oTemplate.Title + '<\/div>' ; if ( oTemplate.Description )
    sInner += '<div>' + oTemplate.Description + '<\/div>' ; sInner += '<\/td><\/tr><\/table>' ; oItemDiv.innerHTML = sInner ;

    oItemDiv.onmouseover = ItemDiv_OnMouseOver ;
    oItemDiv.onmouseout = ItemDiv_OnMouseOut ;
    oItemDiv.onclick = ItemDiv_OnClick ;
    }
    }
    }function ItemDiv_OnMouseOver()
    {
    this.className += ' PopupSelectionBox' ;
    }function ItemDiv_OnMouseOut()
    {
    this.className = this.className.replace( /\s*PopupSelectionBox\s*/, '' ) ;
    }function ItemDiv_OnClick()
    {
    SelectTemplate( this.TplIndex ) ;
    }function SelectTemplate( index )
    {
    oEditor.FCKUndo.SaveUndoStep() ;
    FCK.InsertHtml( FCK._Templates[index].Html ) ;
    window.parent.Cancel() ;
    } </script>
    </head>
    <body scroll="no" style="OVERFLOW: hidden">
    <table width="100%" height="100%">
    <tr>
    <td align="center">
    <span fckLang="DlgTemplatesSelMsg">Please select the template to open in the editor<br>
    (the actual contents will be lost):</span>
    </td>
    </tr>
    <tr>
    <td height="100%" align="center">
    <div id="eList" align="left" class="TplList">
    <div id="eLoading" align="center" style="DISPLAY: none">
    <br>
    <span fckLang="DlgTemplatesLoading">Loading templates list. Please wait...</span>
    </div>
    <div id="eEmpty" align="center" style="DISPLAY: none">
    <br>
    <span fckLang="DlgTemplatesNoTpl">(No templates defined)</span>
    </div>
    </div>
    </td>
    </tr>
    </table>
    </body>
    </html>