Just look at the code.
1, the introduction of Ueditor and Ueditor use I will not elaborate on the details please poke http://blog.csdn.net/wangdianyong/article/details/39780709
2, ueditor.jsp
<!--introducing jquery--
<script type= "Text/javascript" src= "Js/jquery2.0.js" ></script>
<!--Introduction to jquery End--
<!--introduction Ueditor--
<script type= "Text/javascript" src= "Ueditor/ueditor.config.js" ></script>
<script type= "Text/javascript" src= "Ueditor/ueditor.all.min.js" ></script>
<!--introduced Ueditor end--
<!--introduction Localstorage.js--
<script type= "Text/javascript" src= "Js/localstorage.js" ></script>
<!--introduced Localstorage.js end--
<script type= "Text/javascript" >
$ (document). Ready (function () {
var UE = ue.geteditor (' container ');
Ue.addlistener ("Ready", function () {
Editor is ready before you can use it.
var html = localstorage.getitem ("Ctvalue");
alert (HTML);
Ue.setcontent (HTML);
});
});
</script>
<body>
${param.content}
<p>
<span id= "span" name= "span" ></span>
</p>
<form action= "ueditor.jsp" method= "POST" >
<script id= "container" name= "content" type= "Text/plain"
Style= "width:800px;height:400px;" >
</script>
<script type= "Text/javascript" >
var UE = ue.geteditor (' container ');
</script>
<input type= "Submit" value= "Submission" >
</form>
</body>
Localstorage.js
$ (document). Ready (
function () {
if (!window.localstorage) {
Alert (' Your browser does not support Localstorage technology! ');
} else {
var spanobj = $ ("span");
Alert ("Spanobj" + spanobj);
var Savetimer = setinterval (
function () {
var str = "";
if (document.all) {/* IE */
str = document.frames[1].document.body.innerhtml;
} else {/* CHROME,FF */
str =
document.getElementById ("container"). ContentDocument.body.innerHTML;
var UE = ue.geteditor (' container ');
str = ue.getcontent ();
}
if (Str.length > 20
&& (Str.indexof (". ") >-1 | | Str
. IndexOf (",") >-1)) {/*
* Content is only saved
* with a period or comma
*/
Localstorage.setitem ("Ctvalue", str);
var d = new Date ();
var ymdhms = d.getfullyear () + "-"
+ (D.getmonth () + 1) + "-"
+ d.getdate () + ""
+ d.gethours () + ":"
+ d.getminutes () + ":"
+ D.getseconds ();
alert (YMDHMS);
spanobj.innerhtml = ' (Data saved in: ' +
Ymdhms
+ ') ';
// var text = $ ("span"). Text = ' (Data saved in: ')
// + ymdhms + ') ';
$ ("#span"). Text (' (Data saved in: ' + ymdhms + ') ');
// alert (text);
SetTimeout (function () {
Spanobj.innertext = ";
}, 5000);
}
}, 25000); Save once every n seconds
function Stoplocs () {
Clearinterval (Savetimer); Stop saving
Localstorage.removeitem ("Ctvalue"); Empty
}
function Showlocs () {
var html = localstorage.getitem ("Ctvalue");
Editor.setcontent (HTML);
Alert (Localstorage.getitem ("Ctvalue"));
}
}
});
The basic timing saved as a draft content is implemented, you can close your browser to reopen the page to find that their previous edits have not been lost due to unexpected circumstances.
Source
Use Localstorage to save Ueditor edits to a draft on a timed basis