Kindeditor IE10下無(wú)法提交數(shù)據(jù)到數(shù)據(jù)庫(kù)
Kindeditor IE10下無(wú)法提交數(shù)據(jù)到數(shù)據(jù)庫(kù)
最近幫客戶開(kāi)發(fā)網(wǎng)站的時(shí)候,后臺(tái)的編輯器使用了kindeditor,但用戶反應(yīng)無(wú)法保存內(nèi)容。他的環(huán)境是win7 IE10,我在XP IE9下測(cè)試可以提交數(shù)據(jù),在win7 IE10環(huán)境下測(cè)試,確實(shí)有這個(gè)問(wèn)題。因?yàn)樵贗E9下提交無(wú)故障,所以排除了服務(wù)器端腳本問(wèn)題,于是問(wèn)題就定位到網(wǎng)頁(yè)的編輯器上。以下是調(diào)用編輯器的代碼:
頁(yè)面頭部(<head></head>)代碼:
<script type="text/javascript" src="ke/kindeditor.js"></script>
<script src="ke/lang/zh_CN.js"></script>
<script>
var editor;
KindEditor.ready(function(K) {
editor = K.create('#editor_id');
});
var editor = K.create('textarea[name="content"]', options);
html = editor.html();
// 同步數(shù)據(jù)后可以直接取得textarea的value
editor.sync();
html = document.getElementById('editor_id').value; // 原生API
html = K('#editor_id').val(); // KindEditor Node API
html = $('#editor_id').val(); // jQuery
// 設(shè)置HTML內(nèi)容
editor.html('HTML內(nèi)容');
</script>
編輯器展示部分代碼:
<form method="post" name="myform" action="Modify.asp?mark=ok">
<input type=hidden name=id value=<%=id%>>
<td><div align="center">
<table width="100%" border="0" cellspacing="1" cellpadding="0">
<tr bgcolor="#ECF5FF">
<td width="10%" height="25"> <div align="center">欄目名稱:</div></td>
<td width="33%" height="25" bgcolor="#ECF5FF"> <input type="text" name="title" maxlength="30" size="25" value="<%=rs("Title")%>">
</td>
<td width="14%" bgcolor="#ECF5FF"><div align="center">排序號(hào):</div></td>
<td width="12%" bgcolor="#ECF5FF"><input name="Aboutusorder" type="text" id="Aboutusorder" value="<%=rs("Aboutusorder")%>" size="4"></td>
<td width="12%" bgcolor="#ECF5FF"><div align="center">語(yǔ)言:</div></td>
<td width="19%" bgcolor="#ECF5FF"><select name="Language" id="Language">
<option <% if rs("Language")="1" then response.Write "selected" %> value="1">中文</option>
<option <% if rs("Language")="0" then response.Write "selected" %> value="0">英文</option>
</select></td>
</tr>
<tr bgcolor="#ECF5FF">
<td height="25" colspan="6"> <div align="center">欄目?jī)?nèi)容</div></td>
</tr>
<tr bgcolor="#ECF5FF">
<td height="300" colspan="6"> <textarea id="editor_id" name="content" style="width:700px;height:400px;visibility:hidden;"><%=Server.HTMLEncode(rs("Content"))%></textarea>
</td>
</tr>
<tr bgcolor="#ECF5FF">
<td height="25" colspan="6"> <div align="center">
<input name="submit" type="submit" value="確定">
<input name="reset" type="reset" value="重置">
</div></td>
</tr>
</table>
</div></td>
</form>
kindeditor編輯器在提交數(shù)據(jù)的時(shí),有一個(gè)將數(shù)據(jù)同步到文本區(qū)域的操作,而IE10無(wú)法提交數(shù)據(jù),說(shuō)明文本域(texarea)的內(nèi)容是空的,空可能就是因?yàn)橥經(jīng)]有成功,于是在提交表單前,我加了一個(gè)手動(dòng)同步的操作,結(jié)果還真成功了!
具體是:在<form>中加了onsubmit="javascript:editor.sync();",即<form method="post" name="myform" action="Modify.asp?mark=ok" onsubmit="javascript:editor.sync();">
希望您也能成功!
關(guān)鍵詞:Kindeditor