TinyMCE没有在虚拟主机上工作?

时间:2015-10-07 07:48:09

标签: javascript php tinymce virtualhost

我有一个项目可以为我的网站仪表板制作所见即所得的编辑器。所以我已经有了somekind脚本在服务器上工作。例如:natabuana.com/editor
当我在localhost上尝试相同的文件时,它会变成白页,为什么会发生这种情况? CORECTION:在这个地址上http://localhost/editor.php看起来像往常一样工作。并且不使用此地址http://www.natabuana.com/editor.php (still on localhost)

问题是我使用虚拟主机将真实的网址刺激到我的项目中,所以问题可能是Javascript / JQuery on Apache Virtual Host ...

1 个答案:

答案 0 :(得分:0)

这里的问题是你的tinymce初始化发生在加载html dom元素之前。使用它来使它工作:

<!DOCTYPE html>
<html>
<head>
    <script type="text/javascript" src="tinymce/tinymce.min.js"></script>
    <title>JS Rich-Text Editor</title>
</head>
<body style="font-family:fantasy">
    <h1>TinyMCE Getting Started Guide</h1>
    <form method="post" action="editor.php">
    <textarea id="mytextarea" name="content" style="height:256px"></textarea>
    <p><input type="submit" value="submit" /></p>
</form>
</body>
    <script type="text/javascript">
        tinymce.init({ selector: "#mytextarea", menubar:false , plugins: "table image link code", tools: "inserttable", fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt", toolbar: ["code | fontselect | fontsizeselect | bold italic | link image | alignleft aligncenter alignright | table inserttable | undo redo" ] });
    </script>
</html>

替代:

如果你使用jQuery将你的tinymce initalization放入文档就绪电话

<script type="text/javascript">
$(document).ready(function() {
    tinymce.init({ selector: "#mytextarea", menubar:false , plugins: "table image link code", tools: "inserttable", fontsize_formats: "8pt 10pt 12pt 14pt 18pt 24pt 36pt", toolbar: ["code | fontselect | fontsizeselect | bold italic | link image | alignleft aligncenter alignright | table inserttable | undo redo" ] });
});
</script>