注释
以/* 开始
以*/结束
被注释掉的文字会自动隐藏
");
window.frames["iframe_show503"].document.write(decodeHtml($("textarea#stepcodeTextarea503").val()));
window.frames["iframe_show503"].document.close();
$(window.frames["iframe_show503"]).load(function(){
$("#iframe_show503").height($("#iframe_show503").contents().find("body").height()+showittryitheight);
});
$("#iframe_show503").height($("#iframe_show503").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<style>
/*设置所有的p元素中的内容为红色*/
p{
color:red;
}
</style>
<p>红色的p</p>
<style>
/*设置所有的p元素中的内容为红色*/
p{
color:red;
}
</style>
<p>红色的p</p>
");
window.frames["iframe503"].document.write(decodeHtml(code503));
window.frames["iframe503"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe503"]).load(function(){
$("#iframe503").height($("#iframe503").contents().find("body").height()+showittryitheight);
});
$("#iframe503").height($("#iframe503").contents().find("body").height()+showittryitheight);
alreadyWriteCode503 = code503;
$("#rendering503").hide();
$("#rendered503").show();
}
var tRereshRetry2DemoPanel503 = setInterval(rereshRetry2DemoPanel503,1000);
var binded503 = false;
$("textarea#stepcodeTextarea503").keyup(function(){
if(!binded503){
$(window).bind('beforeunload',function(){
binded503 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code503 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code503!=newCode){
// window.frames["iframe503"].document.write("
");
// window.frames["iframe503"].document.write(decodeHtml($("textarea#stepcodeTextarea503").val()));
// window.frames["iframe503"].document.close();
// $(window.frames["iframe503"]).load(function(){
// $("#iframe503").height($("#iframe503").contents().find("body").height()+showittryitheight);
// });
// code503 = newCode;
// }
});
$(".tryButton503").click(function(){
$("#tryDiv503").show();
$("#stepcodeTextarea503").focus();
$("#stepcodeTextarea503").height(200);
$("#iframe503").height(0);
window.frames["iframe503"].document.write("
");
window.frames["iframe503"].document.write(decodeHtml($("textarea#stepcodeTextarea503").val()));
window.frames["iframe503"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe503"]).load(function(){
$("#iframe503").height($("#iframe503").contents().find("body").height()+showittryitheight);
});
$("#iframe503").height($("#iframe503").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor503.focus();
editor503.setSize(null, "250");
$("#rendering503").hide();
$("#rendered503").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 editor503 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea503"), {
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);
}
}
});
editor503.on("change",function(doc){
if(!binded503){
$(window).bind('beforeunload',function(){
binded503 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code503 = newCode;
$("textarea#stepcodeTextarea503").val(newCode);
if(alreadyWriteCode503!=code503){
lastModifedTime503 = new Date().getTime();
$("#rendering503").show();
$("#rendered503").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor503 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor503.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv503").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|