");
window.frames["iframe_show321"].document.write(decodeHtml($("textarea#stepcodeTextarea321").val()));
window.frames["iframe_show321"].document.close();
$(window.frames["iframe_show321"]).load(function(){
$("#iframe_show321").height($("#iframe_show321").contents().find("body").height()+showittryitheight);
});
$("#iframe_show321").height($("#iframe_show321").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<h1 >未设置居中的标题</h1>
<h1 align="center">居中标题</h1>
<h1 >未设置居中的标题</h1>
<h1 align="center">居中标题</h1>
");
window.frames["iframe321"].document.write(decodeHtml(code321));
window.frames["iframe321"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe321"]).load(function(){
$("#iframe321").height($("#iframe321").contents().find("body").height()+showittryitheight);
});
$("#iframe321").height($("#iframe321").contents().find("body").height()+showittryitheight);
alreadyWriteCode321 = code321;
$("#rendering321").hide();
$("#rendered321").show();
}
var tRereshRetry2DemoPanel321 = setInterval(rereshRetry2DemoPanel321,1000);
var binded321 = false;
$("textarea#stepcodeTextarea321").keyup(function(){
if(!binded321){
$(window).bind('beforeunload',function(){
binded321 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code321 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code321!=newCode){
// window.frames["iframe321"].document.write("
");
// window.frames["iframe321"].document.write(decodeHtml($("textarea#stepcodeTextarea321").val()));
// window.frames["iframe321"].document.close();
// $(window.frames["iframe321"]).load(function(){
// $("#iframe321").height($("#iframe321").contents().find("body").height()+showittryitheight);
// });
// code321 = newCode;
// }
});
$(".tryButton321").click(function(){
$("#tryDiv321").show();
$("#stepcodeTextarea321").focus();
$("#stepcodeTextarea321").height(200);
$("#iframe321").height(0);
window.frames["iframe321"].document.write("
");
window.frames["iframe321"].document.write(decodeHtml($("textarea#stepcodeTextarea321").val()));
window.frames["iframe321"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe321"]).load(function(){
$("#iframe321").height($("#iframe321").contents().find("body").height()+showittryitheight);
});
$("#iframe321").height($("#iframe321").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor321.focus();
editor321.setSize(null, "250");
$("#rendering321").hide();
$("#rendered321").hide();
});
var mixedMode = {
name: "htmlmixed",
scriptTypes: [{matches: /\/x-handlebars-template|\/x-mustache/i,
mode: null},
{matches: /(text|application)\/(x-)?vb(a|script)/i,
mode: "vbscript"}]
};
var editor321 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea321"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode:"text/html",
theme:"eclipse",
selectionPointer: true,
lineWrapping: true,
extraKeys: {
"Alt-/": "autocomplete",
"Ctrl-F": "findPersistent",
"F8": function(cm) {
cm.setOption("fullScreen", !cm.getOption("fullScreen"));
},
"Esc": function(cm) {
if (cm.getOption("fullScreen")) cm.setOption("fullScreen", false);
}
}
});
editor321.on("change",function(doc){
if(!binded321){
$(window).bind('beforeunload',function(){
binded321 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code321 = newCode;
$("textarea#stepcodeTextarea321").val(newCode);
if(alreadyWriteCode321!=code321){
lastModifedTime321 = new Date().getTime();
$("#rendering321").show();
$("#rendered321").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor321 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor321.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv321").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|