CKEditor 在本地主机上工作但不在服务器上工作

CKEditor working on localhost but not on server

当 运行 本地应用程序但在 IIS 服务器上托管时,server.Everything 上的 ckeditor 工作正常,ckeditor 不可见。

我尝试了几个步骤,例如添加 ,但仍然遇到同样的问题。我想该页面无法在指定路径上找到 JS 文件。

在控制台中检查我能够在我的页面上看到 ckeditor 脚本。

下面是代码:

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js" type="text/javascript"></script>
<link href = "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="Stylesheet" type="text/css" />
    <script type="text/javascript" src="../ckeditor/ckeditor.js"></script>

  <table style="width: 100%; height: 333px;">
   <tr>
   <td class="auto-style1">&nbsp; Title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;</td>
                    <td>&nbsp; &nbsp;<asp:TextBox ID="txtTitle" runat="server" Height="29px" Width="451px" MaxLength="100"></asp:TextBox>
                        <asp:Label ID="lblNewsId" runat="server" Visible="False"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="auto-style1">&nbsp; Description&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; :&nbsp;</td>
                    <td>&nbsp;&nbsp; &nbsp; <CKEditor:CKEditorControl ID="txtDescp" BasePath="/ckeditor/"   runat="server">
   </CKEditor:CKEditorControl>
                    </td>
                </tr>
                <tr>
                  </table>

您的脚本 src 是相对于您的页面位置(以两个点开头):src="../ckeditor/ckeditor.js"

这意味着如果您的 asp.net 页面位于子文件夹中,则将找不到 ckeditor 文件夹。

您可以使用 ResolveClientUrl() 在运行时呈现正确的 src:

<script type="text/javascript" src="<%=ResolveClientUrl("~/ckeditor/ckedtor.js")%>"></script>

或者,如果您知道您的应用程序位置将在本地和远程保持不变(例如 http://localhost/myapp and also http://myserver/myapp),您可以设置从根开始的 src:

<script type="text/javascript" src="/myapp/ckeditor/ckedtor.js"></script>