TinyMCE没有初始化,但没有JavaScript错误

时间:2015-09-30 00:05:32

标签: javascript jquery tinymce

我有一个非常简单的电子邮件表单(私人俱乐部的会员专用页面)发送电子邮件爆炸。代码很简单:

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="../../../tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
</head>
<body>

<h1>Email Blast</h1>
<form method="post">

<input type="hidden" name="from" value="blast@club.com" />
<input type="hidden" name="to" value="blast@club.com" />
<input type="hidden" name="reply" value="from@club.com" />
<input type="hidden" name="bcc" value="Tester <test@club.com>" />

<label for="subject">Subject</label><br/>
<input type="text" name="subject" id="subject" style="width: 600px" /><br/>

<label for="message">Message</label><br/>
<textarea id="message" name="message" rows="15" cols="100" class="tinymce"></textarea><br/>

<br/><input type="submit" value="Send Email" name="submit">

</form>
</body>
<script type="text/javascript">
jQuery(document).ready(function() {
    tinymce.init({selector:"textarea.tinymce"});
});
</script>

由于某种原因,页面根本没有像我期望的那样呈现textarea.tinymce,但JS控制台中没有错误消息,所有断点都按照我的预期命中。

我错过了什么?

1 个答案:

答案 0 :(得分:1)

您应该在关闭之前将script标记放在body标记内。

如果在关闭body标记后放置任何内容,浏览器将忽略它。

请看下面的示例 - 如果您将script标记放在body标记内,它就像魅力一样:

&#13;
&#13;
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.2.5/tinymce.jquery.min.js"></script>
</head>
<body>

<h1>Email Blast</h1>
<form method="post">

<input type="hidden" name="from" value="blast@club.com" />
<input type="hidden" name="to" value="blast@club.com" />
<input type="hidden" name="reply" value="from@club.com" />
<input type="hidden" name="bcc" value="Tester <test@club.com>" />

<label for="subject">Subject</label><br/>
<input type="text" name="subject" id="subject" style="width: 600px" /><br/>

<label for="message">Message</label><br/>
<textarea id="message" name="message" rows="15" cols="100" class="tinymce"></textarea><br/>

<br/><input type="submit" value="Send Email" name="submit">

</form>
<script type="text/javascript">
jQuery(document).ready(function() {
    tinymce.init({selector:"textarea.tinymce"});
});
</script>
</body>
</html>
&#13;
&#13;
&#13;