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="alert alert-success" role="alert">操作成功</div>
<div class="alert alert-info" role="alert">信息提示</div>
<div class="alert alert-warning" role="alert">警告提示</div>
<div class="alert alert-danger" role="alert">危险提示</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="alert alert-warning alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  警告提示
</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="alert alert-success" role="alert">
  <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a>
</div>
<div class="alert alert-info" role="alert">
  <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a>
</div>
<div class="alert alert-warning" role="alert">
  <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a>
</div>
<div class="alert alert-danger" role="alert">
  <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a>
</div>
警告框中的链接
示例代码
示例 1 : 警告框   
示例 2 : 可关闭的警告框   
示例 3 : 警告框中的链接   

示例 1 :

警告框

警告框
"); window.frames["iframe_show2979"].document.write(decodeHtml($("textarea#stepcodeTextarea2979").val())); window.frames["iframe_show2979"].document.close(); $(window.frames["iframe_show2979"]).load(function(){ $("#iframe_show2979").height($("#iframe_show2979").contents().find("body").height()+showittryitheight); }); $("#iframe_show2979").height($("#iframe_show2979").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="alert alert-success" role="alert">操作成功</div> <div class="alert alert-info" role="alert">信息提示</div> <div class="alert alert-warning" role="alert">警告提示</div> <div class="alert alert-danger" role="alert">危险提示</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="alert alert-success" role="alert">操作成功</div>
<div class="alert alert-info" role="alert">信息提示</div>
<div class="alert alert-warning" role="alert">警告提示</div>
<div class="alert alert-danger" role="alert">危险提示</div>
"); window.frames["iframe2979"].document.write(decodeHtml(code2979)); window.frames["iframe2979"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe2979"]).load(function(){ $("#iframe2979").height($("#iframe2979").contents().find("body").height()+showittryitheight); }); $("#iframe2979").height($("#iframe2979").contents().find("body").height()+showittryitheight); alreadyWriteCode2979 = code2979; $("#rendering2979").hide(); $("#rendered2979").show(); } var tRereshRetry2DemoPanel2979 = setInterval(rereshRetry2DemoPanel2979,1000); var binded2979 = false; $("textarea#stepcodeTextarea2979").keyup(function(){ if(!binded2979){ $(window).bind('beforeunload',function(){ binded2979 = true; return "xxxx"; }); } var newCode = $(this).val() code2979 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code2979!=newCode){ // window.frames["iframe2979"].document.write("
"); // window.frames["iframe2979"].document.write(decodeHtml($("textarea#stepcodeTextarea2979").val())); // window.frames["iframe2979"].document.close(); // $(window.frames["iframe2979"]).load(function(){ // $("#iframe2979").height($("#iframe2979").contents().find("body").height()+showittryitheight); // }); // code2979 = newCode; // } }); $(".tryButton2979").click(function(){ $("#tryDiv2979").show(); $("#stepcodeTextarea2979").focus(); $("#stepcodeTextarea2979").height(200); $("#iframe2979").height(0); window.frames["iframe2979"].document.write("
"); window.frames["iframe2979"].document.write(decodeHtml($("textarea#stepcodeTextarea2979").val())); window.frames["iframe2979"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe2979"]).load(function(){ $("#iframe2979").height($("#iframe2979").contents().find("body").height()+showittryitheight); }); $("#iframe2979").height($("#iframe2979").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor2979.focus(); editor2979.setSize(null, "250"); $("#rendering2979").hide(); $("#rendered2979").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 editor2979 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea2979"), { 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); } } }); editor2979.on("change",function(doc){ if(!binded2979){ $(window).bind('beforeunload',function(){ binded2979 = true; return "xxxx"; }); } var newCode = doc.getValue(); code2979 = newCode; $("textarea#stepcodeTextarea2979").val(newCode); if(alreadyWriteCode2979!=code2979){ lastModifedTime2979 = new Date().getTime(); $("#rendering2979").show(); $("#rendered2979").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor2979 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor2979.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv2979").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

可关闭的警告框

可关闭的警告框
"); window.frames["iframe_show2980"].document.write(decodeHtml($("textarea#stepcodeTextarea2980").val())); window.frames["iframe_show2980"].document.close(); $(window.frames["iframe_show2980"]).load(function(){ $("#iframe_show2980").height($("#iframe_show2980").contents().find("body").height()+showittryitheight); }); $("#iframe_show2980").height($("#iframe_show2980").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="alert alert-warning alert-dismissible" role="alert"> <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button> 警告提示 </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="alert alert-warning alert-dismissible" role="alert">
  <button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  警告提示
</div>
"); window.frames["iframe2980"].document.write(decodeHtml(code2980)); window.frames["iframe2980"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe2980"]).load(function(){ $("#iframe2980").height($("#iframe2980").contents().find("body").height()+showittryitheight); }); $("#iframe2980").height($("#iframe2980").contents().find("body").height()+showittryitheight); alreadyWriteCode2980 = code2980; $("#rendering2980").hide(); $("#rendered2980").show(); } var tRereshRetry2DemoPanel2980 = setInterval(rereshRetry2DemoPanel2980,1000); var binded2980 = false; $("textarea#stepcodeTextarea2980").keyup(function(){ if(!binded2980){ $(window).bind('beforeunload',function(){ binded2980 = true; return "xxxx"; }); } var newCode = $(this).val() code2980 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code2980!=newCode){ // window.frames["iframe2980"].document.write("
"); // window.frames["iframe2980"].document.write(decodeHtml($("textarea#stepcodeTextarea2980").val())); // window.frames["iframe2980"].document.close(); // $(window.frames["iframe2980"]).load(function(){ // $("#iframe2980").height($("#iframe2980").contents().find("body").height()+showittryitheight); // }); // code2980 = newCode; // } }); $(".tryButton2980").click(function(){ $("#tryDiv2980").show(); $("#stepcodeTextarea2980").focus(); $("#stepcodeTextarea2980").height(200); $("#iframe2980").height(0); window.frames["iframe2980"].document.write("
"); window.frames["iframe2980"].document.write(decodeHtml($("textarea#stepcodeTextarea2980").val())); window.frames["iframe2980"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe2980"]).load(function(){ $("#iframe2980").height($("#iframe2980").contents().find("body").height()+showittryitheight); }); $("#iframe2980").height($("#iframe2980").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor2980.focus(); editor2980.setSize(null, "250"); $("#rendering2980").hide(); $("#rendered2980").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 editor2980 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea2980"), { 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); } } }); editor2980.on("change",function(doc){ if(!binded2980){ $(window).bind('beforeunload',function(){ binded2980 = true; return "xxxx"; }); } var newCode = doc.getValue(); code2980 = newCode; $("textarea#stepcodeTextarea2980").val(newCode); if(alreadyWriteCode2980!=code2980){ lastModifedTime2980 = new Date().getTime(); $("#rendering2980").show(); $("#rendered2980").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor2980 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor2980.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv2980").hide(); }); $("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");


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

警告框中的链接

警告框中的链接
"); window.frames["iframe_show2981"].document.write(decodeHtml($("textarea#stepcodeTextarea2981").val())); window.frames["iframe_show2981"].document.close(); $(window.frames["iframe_show2981"]).load(function(){ $("#iframe_show2981").height($("#iframe_show2981").contents().find("body").height()+showittryitheight); }); $("#iframe_show2981").height($("#iframe_show2981").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="alert alert-success" role="alert"> <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a> </div> <div class="alert alert-info" role="alert"> <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a> </div> <div class="alert alert-warning" role="alert"> <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a> </div> <div class="alert alert-danger" role="alert"> <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a> </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="alert alert-success" role="alert">
  <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a>
</div>
<div class="alert alert-info" role="alert">
  <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a>
</div>
<div class="alert alert-warning" role="alert">
  <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a>
</div>
<div class="alert alert-danger" role="alert">
  <span>大减价!!!</span><a href="#nowhere" class="alert-link">点击购买</a>
</div>
"); window.frames["iframe2981"].document.write(decodeHtml(code2981)); window.frames["iframe2981"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe2981"]).load(function(){ $("#iframe2981").height($("#iframe2981").contents().find("body").height()+showittryitheight); }); $("#iframe2981").height($("#iframe2981").contents().find("body").height()+showittryitheight); alreadyWriteCode2981 = code2981; $("#rendering2981").hide(); $("#rendered2981").show(); } var tRereshRetry2DemoPanel2981 = setInterval(rereshRetry2DemoPanel2981,1000); var binded2981 = false; $("textarea#stepcodeTextarea2981").keyup(function(){ if(!binded2981){ $(window).bind('beforeunload',function(){ binded2981 = true; return "xxxx"; }); } var newCode = $(this).val() code2981 = newCode; /*below code is replaced by function rereshRetry2DemoPanel()*/ // if(code2981!=newCode){ // window.frames["iframe2981"].document.write("
"); // window.frames["iframe2981"].document.write(decodeHtml($("textarea#stepcodeTextarea2981").val())); // window.frames["iframe2981"].document.close(); // $(window.frames["iframe2981"]).load(function(){ // $("#iframe2981").height($("#iframe2981").contents().find("body").height()+showittryitheight); // }); // code2981 = newCode; // } }); $(".tryButton2981").click(function(){ $("#tryDiv2981").show(); $("#stepcodeTextarea2981").focus(); $("#stepcodeTextarea2981").height(200); $("#iframe2981").height(0); window.frames["iframe2981"].document.write("
"); window.frames["iframe2981"].document.write(decodeHtml($("textarea#stepcodeTextarea2981").val())); window.frames["iframe2981"].document.close(); //load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式 $(window.frames["iframe2981"]).load(function(){ $("#iframe2981").height($("#iframe2981").contents().find("body").height()+showittryitheight); }); $("#iframe2981").height($("#iframe2981").contents().find("body").height()+showittryitheight); this.scrollIntoView(true); editor2981.focus(); editor2981.setSize(null, "250"); $("#rendering2981").hide(); $("#rendered2981").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 editor2981 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea2981"), { 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); } } }); editor2981.on("change",function(doc){ if(!binded2981){ $(window).bind('beforeunload',function(){ binded2981 = true; return "xxxx"; }); } var newCode = doc.getValue(); code2981 = newCode; $("textarea#stepcodeTextarea2981").val(newCode); if(alreadyWriteCode2981!=code2981){ lastModifedTime2981 = new Date().getTime(); $("#rendering2981").show(); $("#rendered2981").hide(); } // alert(doc.getValue()); }); $(".CodeMirror").addClass("form-control"); // var editor2981 = CodeMirror.fromTextArea(, { // lineNumbers: true, // styleActiveLine: true, // matchBrackets: true, // theme:"eclipse", // }); editor2981.on("change",function(doc){ // alert(doc.getValue()); }); $("#tryDiv2981").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

上传截图