how2j.cn

"); window.frames["iframe_toc"+sid].document.write(decodeHtml($("pre#stepCodePre"+sid).html())); window.frames["iframe_toc"+sid].document.close(); $(window.frames["iframe_toc"+sid]).load(function(){ $("#iframe_toc"+sid).height($("#iframe_toc"+sid).contents().find("body").height()+(showittryitheight)); }); $("#iframe_toc"+sid).height($("#iframe_toc"+sid).contents().find("body").height()+(showittryitheight)); } $("input.tocName").hover(function(){ $(this).select(); }); function refresh(){ var sid = tocstepids.shift(); if(null!=sid) refreshIframe(sid); else go2ArchorFlag = true; } var t = setInterval(refresh,300); // $("div.steptoc iframe").height($(showittryitheight+50)); });
效果 样式(悬停可选中) 说明 示例代码
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-primary">强调</p>
强调的背景
示例代码
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-success">操作成功</p>
成功操作文字的背景
示例代码
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-info">请输入姓名</p>
信息提示文字的背景
示例代码
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-warning">警告语</p>
警告提示文字的背景
示例代码
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-danger">本操作会导致服务器挂掉</p>
危险提示文字的背景
示例代码
示例 1 : 强调的背景   
示例 2 : 成功操作文字的背景   
示例 3 : 信息提示文字的背景   
示例 4 : 警告提示文字的背景   
示例 5 : 危险提示文字的背景   

示例 1 :

强调的背景

一般用在需要强调的文字上
"); window.frames["iframe_show1258"].document.write(decodeHtml($("textarea#stepcodeTextarea1258").val())); window.frames["iframe_show1258"].document.close(); $(window.frames["iframe_show1258"]).load(function(){ $("#iframe_show1258").height($("#iframe_show1258").contents().find("body").height()+showittryitheight); }); $("#iframe_show1258").height($("#iframe_show1258").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<!DOCTYPE html> <script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script> <link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script> <p class="bg-primary">强调</p>
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-primary">强调</p>
"); window.frames["iframe1258"].document.write(decodeHtml(code1258)); window.frames["iframe1258"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1258"]).load(function(){ $("#iframe1258").height($("#iframe1258").contents().find("body").height()+showittryitheight); }); $("#iframe1258").height($("#iframe1258").contents().find("body").height()+showittryitheight); alreadyWriteCode1258 = code1258; $("#rendering1258").hide(); $("#rendered1258").show(); } var tRereshRetry2DemoPanel1258 = setInterval(rereshRetry2DemoPanel1258,1000); var binded1258 = false; $("textarea#stepcodeTextarea1258").keyup(function(){ if(!binded1258){ $(window).bind('beforeunload',function(){ binded1258 = true; return "xxxx"; }); } var newCode = $(this).val() code1258 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1258!=newCode){ // window.frames["iframe1258"].document.write("
"); // window.frames["iframe1258"].document.write(decodeHtml($("textarea#stepcodeTextarea1258").val())); // window.frames["iframe1258"].document.close(); // $(window.frames["iframe1258"]).load(function(){ // $("#iframe1258").height($("#iframe1258").contents().find("body").height()+showittryitheight); // }); // code1258 = newCode; // } }); $(".tryButton1258").click(function(){ $("#tryDiv1258").show(); $("#stepcodeTextarea1258").focus(); $("#stepcodeTextarea1258").height(200); $("#iframe1258").height(0); window.frames["iframe1258"].document.write("
"); window.frames["iframe1258"].document.write(decodeHtml($("textarea#stepcodeTextarea1258").val())); window.frames["iframe1258"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1258"]).load(function(){ $("#iframe1258").height($("#iframe1258").contents().find("body").height()+showittryitheight); }); $("#iframe1258").height($("#iframe1258").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1258.focus(); editor1258.setSize(null, "250"); $("#rendering1258").hide(); $("#rendered1258").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 editor1258 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1258"), { 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); } } }); editor1258.on("change",function(doc){ if(!binded1258){ $(window).bind('beforeunload',function(){ binded1258 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1258 = newCode; $("textarea#stepcodeTextarea1258").val(newCode); if(alreadyWriteCode1258!=code1258){ lastModifedTime1258 = new Date().getTime(); $("#rendering1258").show(); $("#rendered1258").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1258 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1258.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1258").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


源代码
1. 双击选中单词 2. 三击选中整行 3. CTRL+F 查找 4. F8 全屏编辑,再次点击恢复
渲染中 渲染完成
效果
示例 2 :

成功操作文字的背景

一般用在操作成功了的文字上
"); window.frames["iframe_show1259"].document.write(decodeHtml($("textarea#stepcodeTextarea1259").val())); window.frames["iframe_show1259"].document.close(); $(window.frames["iframe_show1259"]).load(function(){ $("#iframe_show1259").height($("#iframe_show1259").contents().find("body").height()+showittryitheight); }); $("#iframe_show1259").height($("#iframe_show1259").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<!DOCTYPE html> <script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script> <link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script> <p class="bg-success">操作成功</p>
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-success">操作成功</p>
"); window.frames["iframe1259"].document.write(decodeHtml(code1259)); window.frames["iframe1259"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1259"]).load(function(){ $("#iframe1259").height($("#iframe1259").contents().find("body").height()+showittryitheight); }); $("#iframe1259").height($("#iframe1259").contents().find("body").height()+showittryitheight); alreadyWriteCode1259 = code1259; $("#rendering1259").hide(); $("#rendered1259").show(); } var tRereshRetry2DemoPanel1259 = setInterval(rereshRetry2DemoPanel1259,1000); var binded1259 = false; $("textarea#stepcodeTextarea1259").keyup(function(){ if(!binded1259){ $(window).bind('beforeunload',function(){ binded1259 = true; return "xxxx"; }); } var newCode = $(this).val() code1259 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1259!=newCode){ // window.frames["iframe1259"].document.write("
"); // window.frames["iframe1259"].document.write(decodeHtml($("textarea#stepcodeTextarea1259").val())); // window.frames["iframe1259"].document.close(); // $(window.frames["iframe1259"]).load(function(){ // $("#iframe1259").height($("#iframe1259").contents().find("body").height()+showittryitheight); // }); // code1259 = newCode; // } }); $(".tryButton1259").click(function(){ $("#tryDiv1259").show(); $("#stepcodeTextarea1259").focus(); $("#stepcodeTextarea1259").height(200); $("#iframe1259").height(0); window.frames["iframe1259"].document.write("
"); window.frames["iframe1259"].document.write(decodeHtml($("textarea#stepcodeTextarea1259").val())); window.frames["iframe1259"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1259"]).load(function(){ $("#iframe1259").height($("#iframe1259").contents().find("body").height()+showittryitheight); }); $("#iframe1259").height($("#iframe1259").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1259.focus(); editor1259.setSize(null, "250"); $("#rendering1259").hide(); $("#rendered1259").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 editor1259 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1259"), { 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); } } }); editor1259.on("change",function(doc){ if(!binded1259){ $(window).bind('beforeunload',function(){ binded1259 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1259 = newCode; $("textarea#stepcodeTextarea1259").val(newCode); if(alreadyWriteCode1259!=code1259){ lastModifedTime1259 = new Date().getTime(); $("#rendering1259").show(); $("#rendered1259").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1259 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1259.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1259").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


源代码
1. 双击选中单词 2. 三击选中整行 3. CTRL+F 查找 4. F8 全屏编辑,再次点击恢复
渲染中 渲染完成
效果
示例 3 :

信息提示文字的背景

一般用在提示性的文字上
"); window.frames["iframe_show1260"].document.write(decodeHtml($("textarea#stepcodeTextarea1260").val())); window.frames["iframe_show1260"].document.close(); $(window.frames["iframe_show1260"]).load(function(){ $("#iframe_show1260").height($("#iframe_show1260").contents().find("body").height()+showittryitheight); }); $("#iframe_show1260").height($("#iframe_show1260").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<!DOCTYPE html> <script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script> <link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script> <p class="bg-info">请输入姓名</p>
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-info">请输入姓名</p>
"); window.frames["iframe1260"].document.write(decodeHtml(code1260)); window.frames["iframe1260"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1260"]).load(function(){ $("#iframe1260").height($("#iframe1260").contents().find("body").height()+showittryitheight); }); $("#iframe1260").height($("#iframe1260").contents().find("body").height()+showittryitheight); alreadyWriteCode1260 = code1260; $("#rendering1260").hide(); $("#rendered1260").show(); } var tRereshRetry2DemoPanel1260 = setInterval(rereshRetry2DemoPanel1260,1000); var binded1260 = false; $("textarea#stepcodeTextarea1260").keyup(function(){ if(!binded1260){ $(window).bind('beforeunload',function(){ binded1260 = true; return "xxxx"; }); } var newCode = $(this).val() code1260 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1260!=newCode){ // window.frames["iframe1260"].document.write("
"); // window.frames["iframe1260"].document.write(decodeHtml($("textarea#stepcodeTextarea1260").val())); // window.frames["iframe1260"].document.close(); // $(window.frames["iframe1260"]).load(function(){ // $("#iframe1260").height($("#iframe1260").contents().find("body").height()+showittryitheight); // }); // code1260 = newCode; // } }); $(".tryButton1260").click(function(){ $("#tryDiv1260").show(); $("#stepcodeTextarea1260").focus(); $("#stepcodeTextarea1260").height(200); $("#iframe1260").height(0); window.frames["iframe1260"].document.write("
"); window.frames["iframe1260"].document.write(decodeHtml($("textarea#stepcodeTextarea1260").val())); window.frames["iframe1260"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1260"]).load(function(){ $("#iframe1260").height($("#iframe1260").contents().find("body").height()+showittryitheight); }); $("#iframe1260").height($("#iframe1260").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1260.focus(); editor1260.setSize(null, "250"); $("#rendering1260").hide(); $("#rendered1260").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 editor1260 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1260"), { 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); } } }); editor1260.on("change",function(doc){ if(!binded1260){ $(window).bind('beforeunload',function(){ binded1260 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1260 = newCode; $("textarea#stepcodeTextarea1260").val(newCode); if(alreadyWriteCode1260!=code1260){ lastModifedTime1260 = new Date().getTime(); $("#rendering1260").show(); $("#rendered1260").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1260 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1260.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1260").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


源代码
1. 双击选中单词 2. 三击选中整行 3. CTRL+F 查找 4. F8 全屏编辑,再次点击恢复
渲染中 渲染完成
效果
示例 4 :

警告提示文字的背景

一般用在警告信息的文字上
"); window.frames["iframe_show1261"].document.write(decodeHtml($("textarea#stepcodeTextarea1261").val())); window.frames["iframe_show1261"].document.close(); $(window.frames["iframe_show1261"]).load(function(){ $("#iframe_show1261").height($("#iframe_show1261").contents().find("body").height()+showittryitheight); }); $("#iframe_show1261").height($("#iframe_show1261").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<!DOCTYPE html> <script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script> <link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script> <p class="bg-warning">警告语</p>
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-warning">警告语</p>
"); window.frames["iframe1261"].document.write(decodeHtml(code1261)); window.frames["iframe1261"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1261"]).load(function(){ $("#iframe1261").height($("#iframe1261").contents().find("body").height()+showittryitheight); }); $("#iframe1261").height($("#iframe1261").contents().find("body").height()+showittryitheight); alreadyWriteCode1261 = code1261; $("#rendering1261").hide(); $("#rendered1261").show(); } var tRereshRetry2DemoPanel1261 = setInterval(rereshRetry2DemoPanel1261,1000); var binded1261 = false; $("textarea#stepcodeTextarea1261").keyup(function(){ if(!binded1261){ $(window).bind('beforeunload',function(){ binded1261 = true; return "xxxx"; }); } var newCode = $(this).val() code1261 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1261!=newCode){ // window.frames["iframe1261"].document.write("
"); // window.frames["iframe1261"].document.write(decodeHtml($("textarea#stepcodeTextarea1261").val())); // window.frames["iframe1261"].document.close(); // $(window.frames["iframe1261"]).load(function(){ // $("#iframe1261").height($("#iframe1261").contents().find("body").height()+showittryitheight); // }); // code1261 = newCode; // } }); $(".tryButton1261").click(function(){ $("#tryDiv1261").show(); $("#stepcodeTextarea1261").focus(); $("#stepcodeTextarea1261").height(200); $("#iframe1261").height(0); window.frames["iframe1261"].document.write("
"); window.frames["iframe1261"].document.write(decodeHtml($("textarea#stepcodeTextarea1261").val())); window.frames["iframe1261"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1261"]).load(function(){ $("#iframe1261").height($("#iframe1261").contents().find("body").height()+showittryitheight); }); $("#iframe1261").height($("#iframe1261").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1261.focus(); editor1261.setSize(null, "250"); $("#rendering1261").hide(); $("#rendered1261").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 editor1261 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1261"), { 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); } } }); editor1261.on("change",function(doc){ if(!binded1261){ $(window).bind('beforeunload',function(){ binded1261 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1261 = newCode; $("textarea#stepcodeTextarea1261").val(newCode); if(alreadyWriteCode1261!=code1261){ lastModifedTime1261 = new Date().getTime(); $("#rendering1261").show(); $("#rendered1261").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1261 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1261.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1261").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


源代码
1. 双击选中单词 2. 三击选中整行 3. CTRL+F 查找 4. F8 全屏编辑,再次点击恢复
渲染中 渲染完成
效果
示例 5 :

危险提示文字的背景

一般用在危险信息的文字上
"); window.frames["iframe_show1262"].document.write(decodeHtml($("textarea#stepcodeTextarea1262").val())); window.frames["iframe_show1262"].document.close(); $(window.frames["iframe_show1262"]).load(function(){ $("#iframe_show1262").height($("#iframe_show1262").contents().find("body").height()+showittryitheight); }); $("#iframe_show1262").height($("#iframe_show1262").contents().find("body").height()+showittryitheight); setTimeout(function(){ },500); });
运行效果
<!DOCTYPE html> <script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script> <link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet"> <script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script> <p class="bg-danger">本操作会导致服务器挂掉</p>
<!DOCTYPE html>
<script src="http://127.0.0.1/study../../../js/jquery/2.0.0/jquery.min.js"></script>
<link href="http://127.0.0.1/study../../../css/bootstrap/3.3.6/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<p class="bg-danger">本操作会导致服务器挂掉</p>
"); window.frames["iframe1262"].document.write(decodeHtml(code1262)); window.frames["iframe1262"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1262"]).load(function(){ $("#iframe1262").height($("#iframe1262").contents().find("body").height()+showittryitheight); }); $("#iframe1262").height($("#iframe1262").contents().find("body").height()+showittryitheight); alreadyWriteCode1262 = code1262; $("#rendering1262").hide(); $("#rendered1262").show(); } var tRereshRetry2DemoPanel1262 = setInterval(rereshRetry2DemoPanel1262,1000); var binded1262 = false; $("textarea#stepcodeTextarea1262").keyup(function(){ if(!binded1262){ $(window).bind('beforeunload',function(){ binded1262 = true; return "xxxx"; }); } var newCode = $(this).val() code1262 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1262!=newCode){ // window.frames["iframe1262"].document.write("
"); // window.frames["iframe1262"].document.write(decodeHtml($("textarea#stepcodeTextarea1262").val())); // window.frames["iframe1262"].document.close(); // $(window.frames["iframe1262"]).load(function(){ // $("#iframe1262").height($("#iframe1262").contents().find("body").height()+showittryitheight); // }); // code1262 = newCode; // } }); $(".tryButton1262").click(function(){ $("#tryDiv1262").show(); $("#stepcodeTextarea1262").focus(); $("#stepcodeTextarea1262").height(200); $("#iframe1262").height(0); window.frames["iframe1262"].document.write("
"); window.frames["iframe1262"].document.write(decodeHtml($("textarea#stepcodeTextarea1262").val())); window.frames["iframe1262"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1262"]).load(function(){ $("#iframe1262").height($("#iframe1262").contents().find("body").height()+showittryitheight); }); $("#iframe1262").height($("#iframe1262").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1262.focus(); editor1262.setSize(null, "250"); $("#rendering1262").hide(); $("#rendered1262").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 editor1262 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1262"), { 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); } } }); editor1262.on("change",function(doc){ if(!binded1262){ $(window).bind('beforeunload',function(){ binded1262 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1262 = newCode; $("textarea#stepcodeTextarea1262").val(newCode); if(alreadyWriteCode1262!=code1262){ lastModifedTime1262 = new Date().getTime(); $("#rendering1262").show(); $("#rendered1262").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1262 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1262.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1262").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


源代码
1. 双击选中单词 2. 三击选中整行 3. CTRL+F 查找 4. F8 全屏编辑,再次点击恢复
渲染中 渲染完成
效果


HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。


关于 前端部分-BootStrap-背景 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 620943819
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: http://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图