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>

      <div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title">提问</h4>
          </div>
          <div class="modal-body">
            <p>问题描述</p>
            <textarea class="form-control"></textarea>
          </div>
          <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
            <button class="btn btn-primary" type="button">提交</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
静态模态窗口
示例代码
<!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>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
 提问(点击弹出模态窗口)
</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title">提问</h4>
          </div>
          <div class="modal-body">
            <p>问题描述</p>
            <textarea class="form-control"></textarea>
          </div>
          <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
            <button class="btn btn-primary" type="button">提交</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
</div>

<div style="height:200px"></div>
点击弹出
示例代码
<!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>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
 提问(点击弹出模态窗口)
</button>
<div class="modal " id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title">提问</h4>
          </div>
          <div class="modal-body">
            <p>问题描述</p>
            <textarea class="form-control"></textarea>
          </div>
          <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
            <button class="btn btn-primary" type="button">提交</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
</div>

<div style="height:200px"></div>
不要动画效果
示例代码
<!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>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
 提问(点击弹出模态窗口)
</button>
<div class="modal fade" id="myModal"  data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title">提问</h4>
          </div>
          <div class="modal-body">
            <p>问题描述</p>
            <textarea class="form-control"></textarea>
          </div>
          <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
            <button class="btn btn-primary" type="button">提交</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
</div>

<div style="height:200px"></div>
点击空白不会收起
示例代码
<!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>
<script>
$(function(){
   $("#open").click(function(){
      $("#myModal").modal('show');
   });
   $("#submit").click(function(){
      alert("信息已经提交");
      $("#myModal").modal('hide');
   });
   $("#toggle").click(function(){
      $("#myModal").modal('toggle');
   });
});
</script>

<button  class="btn btn-default" id="open"> 打开模态窗口</button>
<button class="btn btn-default"  id="close"> 关闭模态窗口</button>
<button class="btn btn-default"  id="toggle"> 切换模态窗口</button>

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title">提问</h4>
          </div>
          <div class="modal-body">
            <p>问题描述</p>
            <textarea class="form-control"></textarea>
          </div>
          <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
            <button class="btn btn-primary" id="submit" type="button">提交</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
</div>
 
<div style="height:200px"></div>
使用JS控制模态窗口
示例代码
<!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>
<script>
$(function(){
    $("#myModal").on("show.bs.modal",function(){
      alert("开始显示模态窗口");
    });
    $("#myModal").on("shown.bs.modal",function(){
      alert("显示模态窗口完毕");
    });
    $("#myModal").on("hide.bs.modal",function(){
      alert("开始隐藏模态窗口");
    });
    $("#myModal").on("hidden.bs.modal",function(){
      alert("隐藏模态窗口完毕");
    });
});
</script>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal">
 提问(点击弹出模态窗口)
</button>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog">
        <div class="modal-content">
          <div class="modal-header">
            <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
            <h4 class="modal-title">提问</h4>
          </div>
          <div class="modal-body">
            <p>问题描述</p>
            <textarea class="form-control"></textarea>
          </div>
          <div class="modal-footer">
            <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button>
            <button class="btn btn-primary" type="button">提交</button>
          </div>
        </div><!-- /.modal-content -->
      </div><!-- /.modal-dialog -->
</div>
 
<div style="height:200px"></div>
监听模态的变化
示例代码
示例 1 : 静态模态窗口   
示例 2 : 点击弹出   
示例 3 : 不要动画效果   
示例 4 : 点击空白不会收起   
示例 5 : 使用JS控制模态窗口   
示例 6 : 监听模态的变化   

示例 1 :

静态模态窗口

静态模态窗口
"); window.frames["iframe_show3000"].document.write(decodeHtml($("textarea#stepcodeTextarea3000").val())); window.frames["iframe_show3000"].document.close(); $(window.frames["iframe_show3000"]).load(function(){ $("#iframe_show3000").height($("#iframe_show3000").contents().find("body").height()+showittryitheight); }); $("#iframe_show3000").height($("#iframe_show3000").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> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title">提问</h4> </div> <div class="modal-body"> <p>问题描述</p> <textarea class="form-control"></textarea> </div> <div class="modal-footer"> <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button> <button class="btn btn-primary" type="button">提交</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog -->
"); window.frames["iframe3000"].document.write(decodeHtml(code3000)); window.frames["iframe3000"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3000"]).load(function(){ $("#iframe3000").height($("#iframe3000").contents().find("body").height()+showittryitheight); }); $("#iframe3000").height($("#iframe3000").contents().find("body").height()+showittryitheight); alreadyWriteCode3000 = code3000; $("#rendering3000").hide(); $("#rendered3000").show(); } var tRereshRetry2DemoPanel3000 = setInterval(rereshRetry2DemoPanel3000,1000); var binded3000 = false; $("textarea#stepcodeTextarea3000").keyup(function(){ if(!binded3000){ $(window).bind('beforeunload',function(){ binded3000 = true; return "xxxx"; }); } var newCode = $(this).val() code3000 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3000!=newCode){ // window.frames["iframe3000"].document.write("
"); // window.frames["iframe3000"].document.write(decodeHtml($("textarea#stepcodeTextarea3000").val())); // window.frames["iframe3000"].document.close(); // $(window.frames["iframe3000"]).load(function(){ // $("#iframe3000").height($("#iframe3000").contents().find("body").height()+showittryitheight); // }); // code3000 = newCode; // } }); $(".tryButton3000").click(function(){ $("#tryDiv3000").show(); $("#stepcodeTextarea3000").focus(); $("#stepcodeTextarea3000").height(200); $("#iframe3000").height(0); window.frames["iframe3000"].document.write("
"); window.frames["iframe3000"].document.write(decodeHtml($("textarea#stepcodeTextarea3000").val())); window.frames["iframe3000"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3000"]).load(function(){ $("#iframe3000").height($("#iframe3000").contents().find("body").height()+showittryitheight); }); $("#iframe3000").height($("#iframe3000").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3000.focus(); editor3000.setSize(null, "250"); $("#rendering3000").hide(); $("#rendered3000").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 editor3000 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3000"), { 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); } } }); editor3000.on("change",function(doc){ if(!binded3000){ $(window).bind('beforeunload',function(){ binded3000 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3000 = newCode; $("textarea#stepcodeTextarea3000").val(newCode); if(alreadyWriteCode3000!=code3000){ lastModifedTime3000 = new Date().getTime(); $("#rendering3000").show(); $("#rendered3000").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3000 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3000.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3000").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

点击弹出

点击弹出
"); window.frames["iframe_show3001"].document.write(decodeHtml($("textarea#stepcodeTextarea3001").val())); window.frames["iframe_show3001"].document.close(); $(window.frames["iframe_show3001"]).load(function(){ $("#iframe_show3001").height($("#iframe_show3001").contents().find("body").height()+showittryitheight); }); $("#iframe_show3001").height($("#iframe_show3001").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> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> 提问(点击弹出模态窗口) </button> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title">提问</h4> </div> <div class="modal-body"> <p>问题描述</p> <textarea class="form-control"></textarea> </div> <div class="modal-footer"> <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button> <button class="btn btn-primary" type="button">提交</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div> <div style="height:200px"></div>
"); window.frames["iframe3001"].document.write(decodeHtml(code3001)); window.frames["iframe3001"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3001"]).load(function(){ $("#iframe3001").height($("#iframe3001").contents().find("body").height()+showittryitheight); }); $("#iframe3001").height($("#iframe3001").contents().find("body").height()+showittryitheight); alreadyWriteCode3001 = code3001; $("#rendering3001").hide(); $("#rendered3001").show(); } var tRereshRetry2DemoPanel3001 = setInterval(rereshRetry2DemoPanel3001,1000); var binded3001 = false; $("textarea#stepcodeTextarea3001").keyup(function(){ if(!binded3001){ $(window).bind('beforeunload',function(){ binded3001 = true; return "xxxx"; }); } var newCode = $(this).val() code3001 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3001!=newCode){ // window.frames["iframe3001"].document.write("
"); // window.frames["iframe3001"].document.write(decodeHtml($("textarea#stepcodeTextarea3001").val())); // window.frames["iframe3001"].document.close(); // $(window.frames["iframe3001"]).load(function(){ // $("#iframe3001").height($("#iframe3001").contents().find("body").height()+showittryitheight); // }); // code3001 = newCode; // } }); $(".tryButton3001").click(function(){ $("#tryDiv3001").show(); $("#stepcodeTextarea3001").focus(); $("#stepcodeTextarea3001").height(200); $("#iframe3001").height(0); window.frames["iframe3001"].document.write("
"); window.frames["iframe3001"].document.write(decodeHtml($("textarea#stepcodeTextarea3001").val())); window.frames["iframe3001"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3001"]).load(function(){ $("#iframe3001").height($("#iframe3001").contents().find("body").height()+showittryitheight); }); $("#iframe3001").height($("#iframe3001").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3001.focus(); editor3001.setSize(null, "250"); $("#rendering3001").hide(); $("#rendered3001").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 editor3001 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3001"), { 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); } } }); editor3001.on("change",function(doc){ if(!binded3001){ $(window).bind('beforeunload',function(){ binded3001 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3001 = newCode; $("textarea#stepcodeTextarea3001").val(newCode); if(alreadyWriteCode3001!=code3001){ lastModifedTime3001 = new Date().getTime(); $("#rendering3001").show(); $("#rendered3001").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3001 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3001.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3001").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

不要动画效果

不要动画效果
"); window.frames["iframe_show3003"].document.write(decodeHtml($("textarea#stepcodeTextarea3003").val())); window.frames["iframe_show3003"].document.close(); $(window.frames["iframe_show3003"]).load(function(){ $("#iframe_show3003").height($("#iframe_show3003").contents().find("body").height()+showittryitheight); }); $("#iframe_show3003").height($("#iframe_show3003").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> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> 提问(点击弹出模态窗口) </button> <div class="modal " id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title">提问</h4> </div> <div class="modal-body"> <p>问题描述</p> <textarea class="form-control"></textarea> </div> <div class="modal-footer"> <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button> <button class="btn btn-primary" type="button">提交</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div> <div style="height:200px"></div>
"); window.frames["iframe3003"].document.write(decodeHtml(code3003)); window.frames["iframe3003"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3003"]).load(function(){ $("#iframe3003").height($("#iframe3003").contents().find("body").height()+showittryitheight); }); $("#iframe3003").height($("#iframe3003").contents().find("body").height()+showittryitheight); alreadyWriteCode3003 = code3003; $("#rendering3003").hide(); $("#rendered3003").show(); } var tRereshRetry2DemoPanel3003 = setInterval(rereshRetry2DemoPanel3003,1000); var binded3003 = false; $("textarea#stepcodeTextarea3003").keyup(function(){ if(!binded3003){ $(window).bind('beforeunload',function(){ binded3003 = true; return "xxxx"; }); } var newCode = $(this).val() code3003 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3003!=newCode){ // window.frames["iframe3003"].document.write("
"); // window.frames["iframe3003"].document.write(decodeHtml($("textarea#stepcodeTextarea3003").val())); // window.frames["iframe3003"].document.close(); // $(window.frames["iframe3003"]).load(function(){ // $("#iframe3003").height($("#iframe3003").contents().find("body").height()+showittryitheight); // }); // code3003 = newCode; // } }); $(".tryButton3003").click(function(){ $("#tryDiv3003").show(); $("#stepcodeTextarea3003").focus(); $("#stepcodeTextarea3003").height(200); $("#iframe3003").height(0); window.frames["iframe3003"].document.write("
"); window.frames["iframe3003"].document.write(decodeHtml($("textarea#stepcodeTextarea3003").val())); window.frames["iframe3003"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3003"]).load(function(){ $("#iframe3003").height($("#iframe3003").contents().find("body").height()+showittryitheight); }); $("#iframe3003").height($("#iframe3003").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3003.focus(); editor3003.setSize(null, "250"); $("#rendering3003").hide(); $("#rendered3003").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 editor3003 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3003"), { 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); } } }); editor3003.on("change",function(doc){ if(!binded3003){ $(window).bind('beforeunload',function(){ binded3003 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3003 = newCode; $("textarea#stepcodeTextarea3003").val(newCode); if(alreadyWriteCode3003!=code3003){ lastModifedTime3003 = new Date().getTime(); $("#rendering3003").show(); $("#rendered3003").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3003 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3003.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3003").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

点击空白不会收起

点击空白不会收起
"); window.frames["iframe_show3005"].document.write(decodeHtml($("textarea#stepcodeTextarea3005").val())); window.frames["iframe_show3005"].document.close(); $(window.frames["iframe_show3005"]).load(function(){ $("#iframe_show3005").height($("#iframe_show3005").contents().find("body").height()+showittryitheight); }); $("#iframe_show3005").height($("#iframe_show3005").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> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> 提问(点击弹出模态窗口) </button> <div class="modal fade" id="myModal" data-backdrop="static" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title">提问</h4> </div> <div class="modal-body"> <p>问题描述</p> <textarea class="form-control"></textarea> </div> <div class="modal-footer"> <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button> <button class="btn btn-primary" type="button">提交</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div> <div style="height:200px"></div>
"); window.frames["iframe3005"].document.write(decodeHtml(code3005)); window.frames["iframe3005"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3005"]).load(function(){ $("#iframe3005").height($("#iframe3005").contents().find("body").height()+showittryitheight); }); $("#iframe3005").height($("#iframe3005").contents().find("body").height()+showittryitheight); alreadyWriteCode3005 = code3005; $("#rendering3005").hide(); $("#rendered3005").show(); } var tRereshRetry2DemoPanel3005 = setInterval(rereshRetry2DemoPanel3005,1000); var binded3005 = false; $("textarea#stepcodeTextarea3005").keyup(function(){ if(!binded3005){ $(window).bind('beforeunload',function(){ binded3005 = true; return "xxxx"; }); } var newCode = $(this).val() code3005 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3005!=newCode){ // window.frames["iframe3005"].document.write("
"); // window.frames["iframe3005"].document.write(decodeHtml($("textarea#stepcodeTextarea3005").val())); // window.frames["iframe3005"].document.close(); // $(window.frames["iframe3005"]).load(function(){ // $("#iframe3005").height($("#iframe3005").contents().find("body").height()+showittryitheight); // }); // code3005 = newCode; // } }); $(".tryButton3005").click(function(){ $("#tryDiv3005").show(); $("#stepcodeTextarea3005").focus(); $("#stepcodeTextarea3005").height(200); $("#iframe3005").height(0); window.frames["iframe3005"].document.write("
"); window.frames["iframe3005"].document.write(decodeHtml($("textarea#stepcodeTextarea3005").val())); window.frames["iframe3005"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3005"]).load(function(){ $("#iframe3005").height($("#iframe3005").contents().find("body").height()+showittryitheight); }); $("#iframe3005").height($("#iframe3005").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3005.focus(); editor3005.setSize(null, "250"); $("#rendering3005").hide(); $("#rendered3005").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 editor3005 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3005"), { 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); } } }); editor3005.on("change",function(doc){ if(!binded3005){ $(window).bind('beforeunload',function(){ binded3005 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3005 = newCode; $("textarea#stepcodeTextarea3005").val(newCode); if(alreadyWriteCode3005!=code3005){ lastModifedTime3005 = new Date().getTime(); $("#rendering3005").show(); $("#rendered3005").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3005 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3005.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3005").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

使用JS控制模态窗口

使用JS控制模态窗口
"); window.frames["iframe_show3004"].document.write(decodeHtml($("textarea#stepcodeTextarea3004").val())); window.frames["iframe_show3004"].document.close(); $(window.frames["iframe_show3004"]).load(function(){ $("#iframe_show3004").height($("#iframe_show3004").contents().find("body").height()+showittryitheight); }); $("#iframe_show3004").height($("#iframe_show3004").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> <script> $(function(){ $("#open").click(function(){ $("#myModal").modal('show'); }); $("#submit").click(function(){ alert("信息已经提交"); $("#myModal").modal('hide'); }); $("#toggle").click(function(){ $("#myModal").modal('toggle'); }); }); </script> <button class="btn btn-default" id="open"> 打开模态窗口</button> <button class="btn btn-default" id="close"> 关闭模态窗口</button> <button class="btn btn-default" id="toggle"> 切换模态窗口</button> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title">提问</h4> </div> <div class="modal-body"> <p>问题描述</p> <textarea class="form-control"></textarea> </div> <div class="modal-footer"> <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button> <button class="btn btn-primary" id="submit" type="button">提交</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div> <div style="height:200px"></div>
"); window.frames["iframe3004"].document.write(decodeHtml(code3004)); window.frames["iframe3004"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3004"]).load(function(){ $("#iframe3004").height($("#iframe3004").contents().find("body").height()+showittryitheight); }); $("#iframe3004").height($("#iframe3004").contents().find("body").height()+showittryitheight); alreadyWriteCode3004 = code3004; $("#rendering3004").hide(); $("#rendered3004").show(); } var tRereshRetry2DemoPanel3004 = setInterval(rereshRetry2DemoPanel3004,1000); var binded3004 = false; $("textarea#stepcodeTextarea3004").keyup(function(){ if(!binded3004){ $(window).bind('beforeunload',function(){ binded3004 = true; return "xxxx"; }); } var newCode = $(this).val() code3004 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3004!=newCode){ // window.frames["iframe3004"].document.write("
"); // window.frames["iframe3004"].document.write(decodeHtml($("textarea#stepcodeTextarea3004").val())); // window.frames["iframe3004"].document.close(); // $(window.frames["iframe3004"]).load(function(){ // $("#iframe3004").height($("#iframe3004").contents().find("body").height()+showittryitheight); // }); // code3004 = newCode; // } }); $(".tryButton3004").click(function(){ $("#tryDiv3004").show(); $("#stepcodeTextarea3004").focus(); $("#stepcodeTextarea3004").height(200); $("#iframe3004").height(0); window.frames["iframe3004"].document.write("
"); window.frames["iframe3004"].document.write(decodeHtml($("textarea#stepcodeTextarea3004").val())); window.frames["iframe3004"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3004"]).load(function(){ $("#iframe3004").height($("#iframe3004").contents().find("body").height()+showittryitheight); }); $("#iframe3004").height($("#iframe3004").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3004.focus(); editor3004.setSize(null, "250"); $("#rendering3004").hide(); $("#rendered3004").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 editor3004 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3004"), { 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); } } }); editor3004.on("change",function(doc){ if(!binded3004){ $(window).bind('beforeunload',function(){ binded3004 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3004 = newCode; $("textarea#stepcodeTextarea3004").val(newCode); if(alreadyWriteCode3004!=code3004){ lastModifedTime3004 = new Date().getTime(); $("#rendering3004").show(); $("#rendered3004").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3004 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3004.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3004").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

监听模态的变化

监听模态的变化
"); window.frames["iframe_show3008"].document.write(decodeHtml($("textarea#stepcodeTextarea3008").val())); window.frames["iframe_show3008"].document.close(); $(window.frames["iframe_show3008"]).load(function(){ $("#iframe_show3008").height($("#iframe_show3008").contents().find("body").height()+showittryitheight); }); $("#iframe_show3008").height($("#iframe_show3008").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> <script> $(function(){ $("#myModal").on("show.bs.modal",function(){ alert("开始显示模态窗口"); }); $("#myModal").on("shown.bs.modal",function(){ alert("显示模态窗口完毕"); }); $("#myModal").on("hide.bs.modal",function(){ alert("开始隐藏模态窗口"); }); $("#myModal").on("hidden.bs.modal",function(){ alert("隐藏模态窗口完毕"); }); }); </script> <button type="button" class="btn btn-primary" data-toggle="modal" data-target="#myModal"> 提问(点击弹出模态窗口) </button> <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <button data-dismiss="modal" class="close" type="button"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title">提问</h4> </div> <div class="modal-body"> <p>问题描述</p> <textarea class="form-control"></textarea> </div> <div class="modal-footer"> <button data-dismiss="modal" class="btn btn-default" type="button">关闭</button> <button class="btn btn-primary" type="button">提交</button> </div> </div><!-- /.modal-content --> </div><!-- /.modal-dialog --> </div> <div style="height:200px"></div>
"); window.frames["iframe3008"].document.write(decodeHtml(code3008)); window.frames["iframe3008"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3008"]).load(function(){ $("#iframe3008").height($("#iframe3008").contents().find("body").height()+showittryitheight); }); $("#iframe3008").height($("#iframe3008").contents().find("body").height()+showittryitheight); alreadyWriteCode3008 = code3008; $("#rendering3008").hide(); $("#rendered3008").show(); } var tRereshRetry2DemoPanel3008 = setInterval(rereshRetry2DemoPanel3008,1000); var binded3008 = false; $("textarea#stepcodeTextarea3008").keyup(function(){ if(!binded3008){ $(window).bind('beforeunload',function(){ binded3008 = true; return "xxxx"; }); } var newCode = $(this).val() code3008 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code3008!=newCode){ // window.frames["iframe3008"].document.write("
"); // window.frames["iframe3008"].document.write(decodeHtml($("textarea#stepcodeTextarea3008").val())); // window.frames["iframe3008"].document.close(); // $(window.frames["iframe3008"]).load(function(){ // $("#iframe3008").height($("#iframe3008").contents().find("body").height()+showittryitheight); // }); // code3008 = newCode; // } }); $(".tryButton3008").click(function(){ $("#tryDiv3008").show(); $("#stepcodeTextarea3008").focus(); $("#stepcodeTextarea3008").height(200); $("#iframe3008").height(0); window.frames["iframe3008"].document.write("
"); window.frames["iframe3008"].document.write(decodeHtml($("textarea#stepcodeTextarea3008").val())); window.frames["iframe3008"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe3008"]).load(function(){ $("#iframe3008").height($("#iframe3008").contents().find("body").height()+showittryitheight); }); $("#iframe3008").height($("#iframe3008").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor3008.focus(); editor3008.setSize(null, "250"); $("#rendering3008").hide(); $("#rendered3008").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 editor3008 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea3008"), { 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); } } }); editor3008.on("change",function(doc){ if(!binded3008){ $(window).bind('beforeunload',function(){ binded3008 = true; return "xxxx"; }); } var newCode = doc.getValue(); code3008 = newCode; $("textarea#stepcodeTextarea3008").val(newCode); if(alreadyWriteCode3008!=code3008){ lastModifedTime3008 = new Date().getTime(); $("#rendering3008").show(); $("#rendered3008").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor3008 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor3008.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv3008").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

上传截图