|
工具版本兼容问题
在代码中提供有效的注释,可以让代码更加易读和便于维护。
javascript有两种注释方式
示例
1
:
单行注释
示例
2
:
多行注释
");
window.frames["iframe_show1070"].document.write(decodeHtml($("textarea#stepcodeTextarea1070").val()));
window.frames["iframe_show1070"].document.close();
$(window.frames["iframe_show1070"]).load(function(){
$("#iframe_show1070").height($("#iframe_show1070").contents().find("body").height()+showittryitheight);
});
$("#iframe_show1070").height($("#iframe_show1070").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script type="text/javascript">
// 单行注释
document.write("hello java");
</script>
<script type="text/javascript">
// 单行注释
document.write("hello java");
</script>
");
window.frames["iframe1070"].document.write(decodeHtml(code1070));
window.frames["iframe1070"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1070"]).load(function(){
$("#iframe1070").height($("#iframe1070").contents().find("body").height()+showittryitheight);
});
$("#iframe1070").height($("#iframe1070").contents().find("body").height()+showittryitheight);
alreadyWriteCode1070 = code1070;
$("#rendering1070").hide();
$("#rendered1070").show();
}
var tRereshRetry2DemoPanel1070 = setInterval(rereshRetry2DemoPanel1070,1000);
var binded1070 = false;
$("textarea#stepcodeTextarea1070").keyup(function(){
if(!binded1070){
$(window).bind('beforeunload',function(){
binded1070 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code1070 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code1070!=newCode){
// window.frames["iframe1070"].document.write("
");
// window.frames["iframe1070"].document.write(decodeHtml($("textarea#stepcodeTextarea1070").val()));
// window.frames["iframe1070"].document.close();
// $(window.frames["iframe1070"]).load(function(){
// $("#iframe1070").height($("#iframe1070").contents().find("body").height()+showittryitheight);
// });
// code1070 = newCode;
// }
});
$(".tryButton1070").click(function(){
$("#tryDiv1070").show();
$("#stepcodeTextarea1070").focus();
$("#stepcodeTextarea1070").height(200);
$("#iframe1070").height(0);
window.frames["iframe1070"].document.write("
");
window.frames["iframe1070"].document.write(decodeHtml($("textarea#stepcodeTextarea1070").val()));
window.frames["iframe1070"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1070"]).load(function(){
$("#iframe1070").height($("#iframe1070").contents().find("body").height()+showittryitheight);
});
$("#iframe1070").height($("#iframe1070").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor1070.focus();
editor1070.setSize(null, "250");
$("#rendering1070").hide();
$("#rendered1070").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 editor1070 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1070"), {
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);
}
}
});
editor1070.on("change",function(doc){
if(!binded1070){
$(window).bind('beforeunload',function(){
binded1070 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code1070 = newCode;
$("textarea#stepcodeTextarea1070").val(newCode);
if(alreadyWriteCode1070!=code1070){
lastModifedTime1070 = new Date().getTime();
$("#rendering1070").show();
$("#rendered1070").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor1070 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor1070.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv1070").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
");
window.frames["iframe_show1071"].document.write(decodeHtml($("textarea#stepcodeTextarea1071").val()));
window.frames["iframe_show1071"].document.close();
$(window.frames["iframe_show1071"]).load(function(){
$("#iframe_show1071").height($("#iframe_show1071").contents().find("body").height()+showittryitheight);
});
$("#iframe_show1071").height($("#iframe_show1071").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<script type="text/javascript">
/*
进行
多行注释
*/
document.write("hello java");
</script>
<script type="text/javascript">
/*
进行
多行注释
*/
document.write("hello java");
</script>
");
window.frames["iframe1071"].document.write(decodeHtml(code1071));
window.frames["iframe1071"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1071"]).load(function(){
$("#iframe1071").height($("#iframe1071").contents().find("body").height()+showittryitheight);
});
$("#iframe1071").height($("#iframe1071").contents().find("body").height()+showittryitheight);
alreadyWriteCode1071 = code1071;
$("#rendering1071").hide();
$("#rendered1071").show();
}
var tRereshRetry2DemoPanel1071 = setInterval(rereshRetry2DemoPanel1071,1000);
var binded1071 = false;
$("textarea#stepcodeTextarea1071").keyup(function(){
if(!binded1071){
$(window).bind('beforeunload',function(){
binded1071 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code1071 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code1071!=newCode){
// window.frames["iframe1071"].document.write("
");
// window.frames["iframe1071"].document.write(decodeHtml($("textarea#stepcodeTextarea1071").val()));
// window.frames["iframe1071"].document.close();
// $(window.frames["iframe1071"]).load(function(){
// $("#iframe1071").height($("#iframe1071").contents().find("body").height()+showittryitheight);
// });
// code1071 = newCode;
// }
});
$(".tryButton1071").click(function(){
$("#tryDiv1071").show();
$("#stepcodeTextarea1071").focus();
$("#stepcodeTextarea1071").height(200);
$("#iframe1071").height(0);
window.frames["iframe1071"].document.write("
");
window.frames["iframe1071"].document.write(decodeHtml($("textarea#stepcodeTextarea1071").val()));
window.frames["iframe1071"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1071"]).load(function(){
$("#iframe1071").height($("#iframe1071").contents().find("body").height()+showittryitheight);
});
$("#iframe1071").height($("#iframe1071").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor1071.focus();
editor1071.setSize(null, "250");
$("#rendering1071").hide();
$("#rendered1071").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 editor1071 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1071"), {
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);
}
}
});
editor1071.on("change",function(doc){
if(!binded1071){
$(window).bind('beforeunload',function(){
binded1071 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code1071 = newCode;
$("textarea#stepcodeTextarea1071").val(newCode);
if(alreadyWriteCode1071!=code1071){
lastModifedTime1071 = new Date().getTime();
$("#rendering1071").show();
$("#rendered1071").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor1071 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor1071.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv1071").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|