<!DOCTYPE html>
<html>
<head>
<title>ueditor</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
</head>
<body>
<div id="container">
<table style="width: 100%;" class="doc-table">
<tr>
<td>
内容
</td>
<td>
<div style="text-align:left;">
<script id="editor" type="text/plain" style="width: 1000px; height: 400px;">
</script>
</div>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: center;">
<input type="button" id="btnSave" value="发布" onclick="getPlainTxt();" />
</td>
</tr>
</table>
</div>
<script type="text/javascript" charset="utf-8" src="/Content/js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/Content/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/Content/js/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="/Content/js/ueditor/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
UE.getEditor('editor');
function getPlainTxt() {
var content = UE.getEditor('editor')
.getContent()
.replace(/\[b\]([^\[]*?)\[\/b\]/igm, '<b>$1</b>')
.replace(/\[i\]([^\[]*?)\[\/i\]/igm, '<i>$1</i>')
.replace(/\[u\]([^\[]*?)\[\/u\]/igm, '<u>$1</u>')
.replace(/\[url=([^\]]*)\]([^\[]*?)\[\/url\]/igm, '<a href="$1">$2</a>')
.replace(/\[img\]([^\[]*?)\[\/img\]/igm, '<img src="$1" />');
alert(content);
$.ajax({
type: "post",
url: '', //提交到后台
data: {
"content": content
},
success: function (msg) {
alert(msg);
}
});
}
</script>
</body>
</html>
在上面写一个JS,然后传过去
本文如未解决您的问题请添加抖音号:51dongshi(抖音搜索懂视),直接咨询即可。