【发布时间】:2016-08-06 11:12:37
【问题描述】:
我正在使用 TinyMCE 插件并希望能够在编辑器中上传图像。我拥有浏览图像并选择它的所有内容,但在它尝试上传之前,我得到了 Uncaught SyntaxError: Unexpected token }
我的 HTML 是这样设置的:
<div id="htmlEdit"></div>
<form id="editorUpload"
target="hiddenFrame"
method="post"
enctype="multipart/form-data"
style="width:0px;height:0;overflow:hidden">
<input type="hidden" id="dzToken" name="dzToken">
<input type="hidden" id="iField" name="iField">
<input name="image" type="file" onchange="$('#editorUpload').submit();this.value='';">
</form>
<iframe id="hiddenFrame"></iframe>
并像这样初始化编辑器
tinymce.init({
selector:"div#htmlEdit",
theme: "modern",
theme_advanced_buttons3_add: "styleprops",
plugins: [
"advlist autolink lists link charmap print preview anchor",
"searchreplace visualblocks code fullscreen",
"insertdatetime media table contextmenu paste image textcolor colorpicker"
],
file_browser_callback: function(field_name, url, type, win) {
if( type==='image' ){
var tkn=getToken();
$("#editorUpload").attr("action", "cgi/cmsUpload.exe");
$("#dzToken").val(tkn);
$('#editorUpload input').click();
}else{
alertify.alert("images only please");
}
},
height: 300,
width: 928,
force_br_newlines: false,
force_p_newlines: false,
forced_root_block: "",
toolbar: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | print preview media | forecolor backcolor emoticons"
});
我最大的问题是 unexpected token } 错误表明它位于主 HTML 页面的第 2 行,所以我无法确定它在我的代码或 TinyMCE 中的中断位置。 js文件。
如果我尝试 Firefox 控制台,错误是: 语法错误:预期的表达式,脚本结束
【问题讨论】: