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="btn-group">
    <button type="button" class="btn btn-default dropdown-toggle "  data-toggle="dropdown">
     default
      <span class="caret"></span>          
    </button>
     
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
 
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>    
 
<div class="btn-group">
    <button type="button" class="btn btn-primary dropdown-toggle "  data-toggle="dropdown">
     primary 
      <span class="caret"></span>          
    </button>
     
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
 
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>    
 
<div class="btn-group">
    <button type="button" class="btn btn-success dropdown-toggle "  data-toggle="dropdown">
     success 
      <span class="caret"></span>          
    </button>
     
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
 
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>    
 
<div class="btn-group">
    <button type="button" class="btn btn-info dropdown-toggle "  data-toggle="dropdown">
     info 
      <span class="caret"></span>          
    </button>
     
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
 
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>    
 
<div class="btn-group">
    <button type="button" class="btn btn-warning dropdown-toggle "  data-toggle="dropdown">
     warning 
      <span class="caret"></span>          
    </button>
     
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
 
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>    
 
<div class="btn-group">
    <button type="button" class="btn btn-danger dropdown-toggle "  data-toggle="dropdown">
     danger 
      <span class="caret"></span>          
    </button>
     
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
 
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>    
 
<div style="height:100px"></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.0.3/bootstrap.min.css" rel="stylesheet">
<script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script>
 
<div class="btn-group">
   <button type="button" class="btn btn-default">默认</button>
   <button type="button" class="btn btn-default dropdown-toggle" 
      data-toggle="dropdown">
      <span class="caret"></span>

   </button>
   <ul class="dropdown-menu" role="menu">
     <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
 
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
   </ul>
</div>

<div style="height:100px"></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>
  
<div class="btn-group">
    <button type="button" class="btn btn-lg btn-default dropdown-toggle " data-toggle="dropdown">
     大号
      <span class="caret"></span>          
    </button>
      
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
  
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>    
 
<div class="btn-group">
    <button type="button" class="btn btn btn-default dropdown-toggle " data-toggle="dropdown">
     默认
      <span class="caret"></span>          
    </button>
      
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
  
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>  
 
<div class="btn-group">
    <button type="button" class="btn btn-sm btn-default dropdown-toggle " data-toggle="dropdown">
     小号
      <span class="caret"></span>          
    </button>
      
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
  
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>  
 
<div class="btn-group">
    <button type="button" class="btn btn-xs btn-default dropdown-toggle " data-toggle="dropdown">
     更小
      <span class="caret"></span>          
    </button>
      
    <ul class="dropdown-menu" role="menu">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
  
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>  
  
<div style="height:100px"></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>
  
<div style="height:150px"></div>

<div class="btn-group dropup">
    <button type="button" class="btn btn-default dropdown-toggle " id="dropdownMenu1" data-toggle="dropdown">
     default
      <span class="caret"></span>          
    </button>
      
    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
      <li>
         <a href="#">HTML</a>             
      </li>
      <li role="presentation">
         <a href="#">CSS</a>              
      </li>
  
      <li role="presentation">
         <a href="#">Javascript</a>           
      </li>
      <li role="presentation">
         <a href="#">AJAX</a>             
      </li>
    </ul>
</div>    

向上弹出式菜单
示例代码
示例 1 : 单按钮下拉菜单   
示例 2 : 分裂式按钮下拉菜单   
示例 3 : 按钮大小   
示例 4 : 向上弹出式菜单   

示例 1 :

单按钮下拉菜单

单按钮下拉菜单
"); window.frames["iframe_show1549"].document.write(decodeHtml($("textarea#stepcodeTextarea1549").val())); window.frames["iframe_show1549"].document.close(); $(window.frames["iframe_show1549"]).load(function(){ $("#iframe_show1549").height($("#iframe_show1549").contents().find("body").height()+showittryitheight); }); $("#iframe_show1549").height($("#iframe_show1549").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="btn-group"> <button type="button" class="btn btn-default dropdown-toggle " data-toggle="dropdown"> default <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div class="btn-group"> <button type="button" class="btn btn-primary dropdown-toggle " data-toggle="dropdown"> primary <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div class="btn-group"> <button type="button" class="btn btn-success dropdown-toggle " data-toggle="dropdown"> success <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div class="btn-group"> <button type="button" class="btn btn-info dropdown-toggle " data-toggle="dropdown"> info <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div class="btn-group"> <button type="button" class="btn btn-warning dropdown-toggle " data-toggle="dropdown"> warning <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div class="btn-group"> <button type="button" class="btn btn-danger dropdown-toggle " data-toggle="dropdown"> danger <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div style="height:100px"></div>
"); window.frames["iframe1549"].document.write(decodeHtml(code1549)); window.frames["iframe1549"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1549"]).load(function(){ $("#iframe1549").height($("#iframe1549").contents().find("body").height()+showittryitheight); }); $("#iframe1549").height($("#iframe1549").contents().find("body").height()+showittryitheight); alreadyWriteCode1549 = code1549; $("#rendering1549").hide(); $("#rendered1549").show(); } var tRereshRetry2DemoPanel1549 = setInterval(rereshRetry2DemoPanel1549,1000); var binded1549 = false; $("textarea#stepcodeTextarea1549").keyup(function(){ if(!binded1549){ $(window).bind('beforeunload',function(){ binded1549 = true; return "xxxx"; }); } var newCode = $(this).val() code1549 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1549!=newCode){ // window.frames["iframe1549"].document.write("
"); // window.frames["iframe1549"].document.write(decodeHtml($("textarea#stepcodeTextarea1549").val())); // window.frames["iframe1549"].document.close(); // $(window.frames["iframe1549"]).load(function(){ // $("#iframe1549").height($("#iframe1549").contents().find("body").height()+showittryitheight); // }); // code1549 = newCode; // } }); $(".tryButton1549").click(function(){ $("#tryDiv1549").show(); $("#stepcodeTextarea1549").focus(); $("#stepcodeTextarea1549").height(200); $("#iframe1549").height(0); window.frames["iframe1549"].document.write("
"); window.frames["iframe1549"].document.write(decodeHtml($("textarea#stepcodeTextarea1549").val())); window.frames["iframe1549"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1549"]).load(function(){ $("#iframe1549").height($("#iframe1549").contents().find("body").height()+showittryitheight); }); $("#iframe1549").height($("#iframe1549").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1549.focus(); editor1549.setSize(null, "250"); $("#rendering1549").hide(); $("#rendered1549").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 editor1549 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1549"), { 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); } } }); editor1549.on("change",function(doc){ if(!binded1549){ $(window).bind('beforeunload',function(){ binded1549 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1549 = newCode; $("textarea#stepcodeTextarea1549").val(newCode); if(alreadyWriteCode1549!=code1549){ lastModifedTime1549 = new Date().getTime(); $("#rendering1549").show(); $("#rendered1549").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1549 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1549.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1549").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

分裂式按钮下拉菜单

分裂式按钮下拉菜单
"); window.frames["iframe_show1550"].document.write(decodeHtml($("textarea#stepcodeTextarea1550").val())); window.frames["iframe_show1550"].document.close(); $(window.frames["iframe_show1550"]).load(function(){ $("#iframe_show1550").height($("#iframe_show1550").contents().find("body").height()+showittryitheight); }); $("#iframe_show1550").height($("#iframe_show1550").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.0.3/bootstrap.min.css" rel="stylesheet"> <script src="http://127.0.0.1/study../../../js/bootstrap/3.3.6/bootstrap.min.js"></script> <div class="btn-group"> <button type="button" class="btn btn-default">默认</button> <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"> <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div style="height:100px"></div>
"); window.frames["iframe1550"].document.write(decodeHtml(code1550)); window.frames["iframe1550"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1550"]).load(function(){ $("#iframe1550").height($("#iframe1550").contents().find("body").height()+showittryitheight); }); $("#iframe1550").height($("#iframe1550").contents().find("body").height()+showittryitheight); alreadyWriteCode1550 = code1550; $("#rendering1550").hide(); $("#rendered1550").show(); } var tRereshRetry2DemoPanel1550 = setInterval(rereshRetry2DemoPanel1550,1000); var binded1550 = false; $("textarea#stepcodeTextarea1550").keyup(function(){ if(!binded1550){ $(window).bind('beforeunload',function(){ binded1550 = true; return "xxxx"; }); } var newCode = $(this).val() code1550 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1550!=newCode){ // window.frames["iframe1550"].document.write("
"); // window.frames["iframe1550"].document.write(decodeHtml($("textarea#stepcodeTextarea1550").val())); // window.frames["iframe1550"].document.close(); // $(window.frames["iframe1550"]).load(function(){ // $("#iframe1550").height($("#iframe1550").contents().find("body").height()+showittryitheight); // }); // code1550 = newCode; // } }); $(".tryButton1550").click(function(){ $("#tryDiv1550").show(); $("#stepcodeTextarea1550").focus(); $("#stepcodeTextarea1550").height(200); $("#iframe1550").height(0); window.frames["iframe1550"].document.write("
"); window.frames["iframe1550"].document.write(decodeHtml($("textarea#stepcodeTextarea1550").val())); window.frames["iframe1550"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1550"]).load(function(){ $("#iframe1550").height($("#iframe1550").contents().find("body").height()+showittryitheight); }); $("#iframe1550").height($("#iframe1550").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1550.focus(); editor1550.setSize(null, "250"); $("#rendering1550").hide(); $("#rendered1550").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 editor1550 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1550"), { 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); } } }); editor1550.on("change",function(doc){ if(!binded1550){ $(window).bind('beforeunload',function(){ binded1550 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1550 = newCode; $("textarea#stepcodeTextarea1550").val(newCode); if(alreadyWriteCode1550!=code1550){ lastModifedTime1550 = new Date().getTime(); $("#rendering1550").show(); $("#rendered1550").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1550 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1550.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1550").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

按钮大小

按钮大小
"); window.frames["iframe_show1551"].document.write(decodeHtml($("textarea#stepcodeTextarea1551").val())); window.frames["iframe_show1551"].document.close(); $(window.frames["iframe_show1551"]).load(function(){ $("#iframe_show1551").height($("#iframe_show1551").contents().find("body").height()+showittryitheight); }); $("#iframe_show1551").height($("#iframe_show1551").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="btn-group"> <button type="button" class="btn btn-lg btn-default dropdown-toggle " data-toggle="dropdown"> 大号 <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div class="btn-group"> <button type="button" class="btn btn btn-default dropdown-toggle " data-toggle="dropdown"> 默认 <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div class="btn-group"> <button type="button" class="btn btn-sm btn-default dropdown-toggle " data-toggle="dropdown"> 小号 <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div class="btn-group"> <button type="button" class="btn btn-xs btn-default dropdown-toggle " data-toggle="dropdown"> 更小 <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div> <div style="height:100px"></div>
"); window.frames["iframe1551"].document.write(decodeHtml(code1551)); window.frames["iframe1551"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1551"]).load(function(){ $("#iframe1551").height($("#iframe1551").contents().find("body").height()+showittryitheight); }); $("#iframe1551").height($("#iframe1551").contents().find("body").height()+showittryitheight); alreadyWriteCode1551 = code1551; $("#rendering1551").hide(); $("#rendered1551").show(); } var tRereshRetry2DemoPanel1551 = setInterval(rereshRetry2DemoPanel1551,1000); var binded1551 = false; $("textarea#stepcodeTextarea1551").keyup(function(){ if(!binded1551){ $(window).bind('beforeunload',function(){ binded1551 = true; return "xxxx"; }); } var newCode = $(this).val() code1551 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1551!=newCode){ // window.frames["iframe1551"].document.write("
"); // window.frames["iframe1551"].document.write(decodeHtml($("textarea#stepcodeTextarea1551").val())); // window.frames["iframe1551"].document.close(); // $(window.frames["iframe1551"]).load(function(){ // $("#iframe1551").height($("#iframe1551").contents().find("body").height()+showittryitheight); // }); // code1551 = newCode; // } }); $(".tryButton1551").click(function(){ $("#tryDiv1551").show(); $("#stepcodeTextarea1551").focus(); $("#stepcodeTextarea1551").height(200); $("#iframe1551").height(0); window.frames["iframe1551"].document.write("
"); window.frames["iframe1551"].document.write(decodeHtml($("textarea#stepcodeTextarea1551").val())); window.frames["iframe1551"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1551"]).load(function(){ $("#iframe1551").height($("#iframe1551").contents().find("body").height()+showittryitheight); }); $("#iframe1551").height($("#iframe1551").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1551.focus(); editor1551.setSize(null, "250"); $("#rendering1551").hide(); $("#rendered1551").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 editor1551 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1551"), { 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); } } }); editor1551.on("change",function(doc){ if(!binded1551){ $(window).bind('beforeunload',function(){ binded1551 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1551 = newCode; $("textarea#stepcodeTextarea1551").val(newCode); if(alreadyWriteCode1551!=code1551){ lastModifedTime1551 = new Date().getTime(); $("#rendering1551").show(); $("#rendered1551").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1551 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1551.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1551").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

向上弹出式菜单

向上弹出式菜单
"); window.frames["iframe_show1552"].document.write(decodeHtml($("textarea#stepcodeTextarea1552").val())); window.frames["iframe_show1552"].document.close(); $(window.frames["iframe_show1552"]).load(function(){ $("#iframe_show1552").height($("#iframe_show1552").contents().find("body").height()+showittryitheight); }); $("#iframe_show1552").height($("#iframe_show1552").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 style="height:150px"></div> <div class="btn-group dropup"> <button type="button" class="btn btn-default dropdown-toggle " id="dropdownMenu1" data-toggle="dropdown"> default <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"> <li> <a href="#">HTML</a> </li> <li role="presentation"> <a href="#">CSS</a> </li> <li role="presentation"> <a href="#">Javascript</a> </li> <li role="presentation"> <a href="#">AJAX</a> </li> </ul> </div>
"); window.frames["iframe1552"].document.write(decodeHtml(code1552)); window.frames["iframe1552"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1552"]).load(function(){ $("#iframe1552").height($("#iframe1552").contents().find("body").height()+showittryitheight); }); $("#iframe1552").height($("#iframe1552").contents().find("body").height()+showittryitheight); alreadyWriteCode1552 = code1552; $("#rendering1552").hide(); $("#rendered1552").show(); } var tRereshRetry2DemoPanel1552 = setInterval(rereshRetry2DemoPanel1552,1000); var binded1552 = false; $("textarea#stepcodeTextarea1552").keyup(function(){ if(!binded1552){ $(window).bind('beforeunload',function(){ binded1552 = true; return "xxxx"; }); } var newCode = $(this).val() code1552 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code1552!=newCode){ // window.frames["iframe1552"].document.write("
"); // window.frames["iframe1552"].document.write(decodeHtml($("textarea#stepcodeTextarea1552").val())); // window.frames["iframe1552"].document.close(); // $(window.frames["iframe1552"]).load(function(){ // $("#iframe1552").height($("#iframe1552").contents().find("body").height()+showittryitheight); // }); // code1552 = newCode; // } }); $(".tryButton1552").click(function(){ $("#tryDiv1552").show(); $("#stepcodeTextarea1552").focus(); $("#stepcodeTextarea1552").height(200); $("#iframe1552").height(0); window.frames["iframe1552"].document.write("
"); window.frames["iframe1552"].document.write(decodeHtml($("textarea#stepcodeTextarea1552").val())); window.frames["iframe1552"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe1552"]).load(function(){ $("#iframe1552").height($("#iframe1552").contents().find("body").height()+showittryitheight); }); $("#iframe1552").height($("#iframe1552").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor1552.focus(); editor1552.setSize(null, "250"); $("#rendering1552").hide(); $("#rendered1552").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 editor1552 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1552"), { 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); } } }); editor1552.on("change",function(doc){ if(!binded1552){ $(window).bind('beforeunload',function(){ binded1552 = true; return "xxxx"; }); } var newCode = doc.getValue(); code1552 = newCode; $("textarea#stepcodeTextarea1552").val(newCode); if(alreadyWriteCode1552!=code1552){ lastModifedTime1552 = new Date().getTime(); $("#rendering1552").show(); $("#rendered1552").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor1552 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor1552.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv1552").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

上传截图