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

TinyMCE not initializing, but no JavaScript errors

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

<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 控制台中没有错误消息,并且所有断点都按我预期的那样命中。

我错过了什么?

您应该将 script 标签放在 body 标签内,就在关闭它之前。

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

请看下面的示例 - 如果将 script 标签放在 body 标签内,效果非常好:

<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>