|
示例
1
:
创建JSON数组
示例
2
:
访问JSON数组
");
window.frames["iframe_show1239"].document.write(decodeHtml($("textarea#stepcodeTextarea1239").val()));
window.frames["iframe_show1239"].document.close();
$(window.frames["iframe_show1239"]).load(function(){
$("#iframe_show1239").height($("#iframe_show1239").contents().find("body").height()+showittryitheight);
});
$("#iframe_show1239").height($("#iframe_show1239").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script>
var heros=
[
{"name":"盖伦","hp":616},
{"name":"提莫","hp":313},
{"name":"死歌","hp":432},
{"name":"火女","hp":389}
]
document.write("JSON数组大小"+heros.length);
</script>
<script>
var heros=
[
{"name":"盖伦","hp":616},
{"name":"提莫","hp":313},
{"name":"死歌","hp":432},
{"name":"火女","hp":389}
]
document.write("JSON数组大小"+heros.length);
</script>
");
window.frames["iframe1239"].document.write(decodeHtml(code1239));
window.frames["iframe1239"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1239"]).load(function(){
$("#iframe1239").height($("#iframe1239").contents().find("body").height()+showittryitheight);
});
$("#iframe1239").height($("#iframe1239").contents().find("body").height()+showittryitheight);
alreadyWriteCode1239 = code1239;
$("#rendering1239").hide();
$("#rendered1239").show();
}
var tRereshRetry2DemoPanel1239 = setInterval(rereshRetry2DemoPanel1239,1000);
var binded1239 = false;
$("textarea#stepcodeTextarea1239").keyup(function(){
if(!binded1239){
$(window).bind('beforeunload',function(){
binded1239 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code1239 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code1239!=newCode){
// window.frames["iframe1239"].document.write("
");
// window.frames["iframe1239"].document.write(decodeHtml($("textarea#stepcodeTextarea1239").val()));
// window.frames["iframe1239"].document.close();
// $(window.frames["iframe1239"]).load(function(){
// $("#iframe1239").height($("#iframe1239").contents().find("body").height()+showittryitheight);
// });
// code1239 = newCode;
// }
});
$(".tryButton1239").click(function(){
$("#tryDiv1239").show();
$("#stepcodeTextarea1239").focus();
$("#stepcodeTextarea1239").height(200);
$("#iframe1239").height(0);
window.frames["iframe1239"].document.write("
");
window.frames["iframe1239"].document.write(decodeHtml($("textarea#stepcodeTextarea1239").val()));
window.frames["iframe1239"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1239"]).load(function(){
$("#iframe1239").height($("#iframe1239").contents().find("body").height()+showittryitheight);
});
$("#iframe1239").height($("#iframe1239").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor1239.focus();
editor1239.setSize(null, "250");
$("#rendering1239").hide();
$("#rendered1239").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 editor1239 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1239"), {
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);
}
}
});
editor1239.on("change",function(doc){
if(!binded1239){
$(window).bind('beforeunload',function(){
binded1239 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code1239 = newCode;
$("textarea#stepcodeTextarea1239").val(newCode);
if(alreadyWriteCode1239!=code1239){
lastModifedTime1239 = new Date().getTime();
$("#rendering1239").show();
$("#rendered1239").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor1239 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor1239.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv1239").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show1240"].document.write(decodeHtml($("textarea#stepcodeTextarea1240").val()));
window.frames["iframe_show1240"].document.close();
$(window.frames["iframe_show1240"]).load(function(){
$("#iframe_show1240").height($("#iframe_show1240").contents().find("body").height()+showittryitheight);
});
$("#iframe_show1240").height($("#iframe_show1240").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script>
var heros=
[
{"name":"盖伦","hp":616},
{"name":"提莫","hp":313},
{"name":"死哥","hp":432},
{"name":"火女","hp":389}
]
document.write( "第4个英雄是:" + heros[3].name);
</script>
<script>
var heros=
[
{"name":"盖伦","hp":616},
{"name":"提莫","hp":313},
{"name":"死哥","hp":432},
{"name":"火女","hp":389}
]
document.write( "第4个英雄是:" + heros[3].name);
</script>
");
window.frames["iframe1240"].document.write(decodeHtml(code1240));
window.frames["iframe1240"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1240"]).load(function(){
$("#iframe1240").height($("#iframe1240").contents().find("body").height()+showittryitheight);
});
$("#iframe1240").height($("#iframe1240").contents().find("body").height()+showittryitheight);
alreadyWriteCode1240 = code1240;
$("#rendering1240").hide();
$("#rendered1240").show();
}
var tRereshRetry2DemoPanel1240 = setInterval(rereshRetry2DemoPanel1240,1000);
var binded1240 = false;
$("textarea#stepcodeTextarea1240").keyup(function(){
if(!binded1240){
$(window).bind('beforeunload',function(){
binded1240 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code1240 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code1240!=newCode){
// window.frames["iframe1240"].document.write("
");
// window.frames["iframe1240"].document.write(decodeHtml($("textarea#stepcodeTextarea1240").val()));
// window.frames["iframe1240"].document.close();
// $(window.frames["iframe1240"]).load(function(){
// $("#iframe1240").height($("#iframe1240").contents().find("body").height()+showittryitheight);
// });
// code1240 = newCode;
// }
});
$(".tryButton1240").click(function(){
$("#tryDiv1240").show();
$("#stepcodeTextarea1240").focus();
$("#stepcodeTextarea1240").height(200);
$("#iframe1240").height(0);
window.frames["iframe1240"].document.write("
");
window.frames["iframe1240"].document.write(decodeHtml($("textarea#stepcodeTextarea1240").val()));
window.frames["iframe1240"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1240"]).load(function(){
$("#iframe1240").height($("#iframe1240").contents().find("body").height()+showittryitheight);
});
$("#iframe1240").height($("#iframe1240").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor1240.focus();
editor1240.setSize(null, "250");
$("#rendering1240").hide();
$("#rendered1240").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 editor1240 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1240"), {
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);
}
}
});
editor1240.on("change",function(doc){
if(!binded1240){
$(window).bind('beforeunload',function(){
binded1240 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code1240 = newCode;
$("textarea#stepcodeTextarea1240").val(newCode);
if(alreadyWriteCode1240!=code1240){
lastModifedTime1240 = new Date().getTime();
$("#rendering1240").show();
$("#rendered1240").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor1240 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor1240.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv1240").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|