|
示例
1
:
表单
示例
2
:
method="get"
示例
3
:
method="post"
示例
4
:
get和post的区别
action="/study/login.jsp" 表示把账号和密码提交到login.jsp这个页面去 注: 这里把数据提交到服务端的login.jsp去了,鉴于当前学习的进度,就不对JSP的内容展开了。 JSP的内容可以到 JSP章节进行学习 注: 有好奇的同学可以参考图片中的login.jsp
");
window.frames["iframe_show360"].document.write(decodeHtml($("textarea#stepcodeTextarea360").val()));
window.frames["iframe_show360"].document.close();
$(window.frames["iframe_show360"]).load(function(){
$("#iframe_show360").height($("#iframe_show360").contents().find("body").height()+showittryitheight);
});
$("#iframe_show360").height($("#iframe_show360").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<form action="http://127.0.0.1/study/login.jsp">
账号:<input type="text" name="name"> <br/>
密码:<input type="password" name="password" > <br/>
<input type="submit" value="登陆">
</form>
<form action="http://127.0.0.1/study/login.jsp">
账号:<input type="text" name="name"> <br/>
密码:<input type="password" name="password" > <br/>
<input type="submit" value="登陆">
</form>
");
window.frames["iframe360"].document.write(decodeHtml(code360));
window.frames["iframe360"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe360"]).load(function(){
$("#iframe360").height($("#iframe360").contents().find("body").height()+showittryitheight);
});
$("#iframe360").height($("#iframe360").contents().find("body").height()+showittryitheight);
alreadyWriteCode360 = code360;
$("#rendering360").hide();
$("#rendered360").show();
}
var tRereshRetry2DemoPanel360 = setInterval(rereshRetry2DemoPanel360,1000);
var binded360 = false;
$("textarea#stepcodeTextarea360").keyup(function(){
if(!binded360){
$(window).bind('beforeunload',function(){
binded360 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code360 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code360!=newCode){
// window.frames["iframe360"].document.write("
");
// window.frames["iframe360"].document.write(decodeHtml($("textarea#stepcodeTextarea360").val()));
// window.frames["iframe360"].document.close();
// $(window.frames["iframe360"]).load(function(){
// $("#iframe360").height($("#iframe360").contents().find("body").height()+showittryitheight);
// });
// code360 = newCode;
// }
});
$(".tryButton360").click(function(){
$("#tryDiv360").show();
$("#stepcodeTextarea360").focus();
$("#stepcodeTextarea360").height(200);
$("#iframe360").height(0);
window.frames["iframe360"].document.write("
");
window.frames["iframe360"].document.write(decodeHtml($("textarea#stepcodeTextarea360").val()));
window.frames["iframe360"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe360"]).load(function(){
$("#iframe360").height($("#iframe360").contents().find("body").height()+showittryitheight);
});
$("#iframe360").height($("#iframe360").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor360.focus();
editor360.setSize(null, "250");
$("#rendering360").hide();
$("#rendered360").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 editor360 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea360"), {
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);
}
}
});
editor360.on("change",function(doc){
if(!binded360){
$(window).bind('beforeunload',function(){
binded360 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code360 = newCode;
$("textarea#stepcodeTextarea360").val(newCode);
if(alreadyWriteCode360!=code360){
lastModifedTime360 = new Date().getTime();
$("#rendering360").show();
$("#rendered360").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor360 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor360.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv360").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
使用method="get" 提交数据 是常用的提交数据的方式
如果form元素没有提供method属性,默认就是get方式提交数据
get方式的一个特点就是,可以在浏览器的地址栏看到提交的参数,即便是密码也看得到
");
window.frames["iframe_show1233"].document.write(decodeHtml($("textarea#stepcodeTextarea1233").val()));
window.frames["iframe_show1233"].document.close();
$(window.frames["iframe_show1233"]).load(function(){
$("#iframe_show1233").height($("#iframe_show1233").contents().find("body").height()+showittryitheight);
});
$("#iframe_show1233").height($("#iframe_show1233").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<form method="get" action="http://127.0.0.1/study/login.jsp">
账号:<input type="text" name="name"> <br/>
密码:<input type="password" name="password" > <br/>
<input type="submit" value="登陆">
</form>
<form method="get" action="http://127.0.0.1/study/login.jsp">
账号:<input type="text" name="name"> <br/>
密码:<input type="password" name="password" > <br/>
<input type="submit" value="登陆">
</form>
");
window.frames["iframe1233"].document.write(decodeHtml(code1233));
window.frames["iframe1233"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1233"]).load(function(){
$("#iframe1233").height($("#iframe1233").contents().find("body").height()+showittryitheight);
});
$("#iframe1233").height($("#iframe1233").contents().find("body").height()+showittryitheight);
alreadyWriteCode1233 = code1233;
$("#rendering1233").hide();
$("#rendered1233").show();
}
var tRereshRetry2DemoPanel1233 = setInterval(rereshRetry2DemoPanel1233,1000);
var binded1233 = false;
$("textarea#stepcodeTextarea1233").keyup(function(){
if(!binded1233){
$(window).bind('beforeunload',function(){
binded1233 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code1233 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code1233!=newCode){
// window.frames["iframe1233"].document.write("
");
// window.frames["iframe1233"].document.write(decodeHtml($("textarea#stepcodeTextarea1233").val()));
// window.frames["iframe1233"].document.close();
// $(window.frames["iframe1233"]).load(function(){
// $("#iframe1233").height($("#iframe1233").contents().find("body").height()+showittryitheight);
// });
// code1233 = newCode;
// }
});
$(".tryButton1233").click(function(){
$("#tryDiv1233").show();
$("#stepcodeTextarea1233").focus();
$("#stepcodeTextarea1233").height(200);
$("#iframe1233").height(0);
window.frames["iframe1233"].document.write("
");
window.frames["iframe1233"].document.write(decodeHtml($("textarea#stepcodeTextarea1233").val()));
window.frames["iframe1233"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1233"]).load(function(){
$("#iframe1233").height($("#iframe1233").contents().find("body").height()+showittryitheight);
});
$("#iframe1233").height($("#iframe1233").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor1233.focus();
editor1233.setSize(null, "250");
$("#rendering1233").hide();
$("#rendered1233").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 editor1233 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1233"), {
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);
}
}
});
editor1233.on("change",function(doc){
if(!binded1233){
$(window).bind('beforeunload',function(){
binded1233 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code1233 = newCode;
$("textarea#stepcodeTextarea1233").val(newCode);
if(alreadyWriteCode1233!=code1233){
lastModifedTime1233 = new Date().getTime();
$("#rendering1233").show();
$("#rendered1233").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor1233 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor1233.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv1233").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
使用method="post" 也可以提交数据
post不会在地址栏显示提交的参数
如果要提交二进制数据,比如上传文件,必须采用post方式
");
window.frames["iframe_show1234"].document.write(decodeHtml($("textarea#stepcodeTextarea1234").val()));
window.frames["iframe_show1234"].document.close();
$(window.frames["iframe_show1234"]).load(function(){
$("#iframe_show1234").height($("#iframe_show1234").contents().find("body").height()+showittryitheight);
});
$("#iframe_show1234").height($("#iframe_show1234").contents().find("body").height()+showittryitheight);
setTimeout(function(){
},500);
});
<form method="post" action="http://127.0.0.1/study/login.jsp">
账号:<input type="text" name="name"> <br/>
密码:<input type="password" name="password" > <br/>
<input type="submit" value="登陆">
</form>
<form method="post" action="http://127.0.0.1/study/login.jsp">
账号:<input type="text" name="name"> <br/>
密码:<input type="password" name="password" > <br/>
<input type="submit" value="登陆">
</form>
");
window.frames["iframe1234"].document.write(decodeHtml(code1234));
window.frames["iframe1234"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1234"]).load(function(){
$("#iframe1234").height($("#iframe1234").contents().find("body").height()+showittryitheight);
});
$("#iframe1234").height($("#iframe1234").contents().find("body").height()+showittryitheight);
alreadyWriteCode1234 = code1234;
$("#rendering1234").hide();
$("#rendered1234").show();
}
var tRereshRetry2DemoPanel1234 = setInterval(rereshRetry2DemoPanel1234,1000);
var binded1234 = false;
$("textarea#stepcodeTextarea1234").keyup(function(){
if(!binded1234){
$(window).bind('beforeunload',function(){
binded1234 = true;
return "xxxx";
});
}
var newCode = $(this).val()
code1234 = newCode;
/*below code is replaced by function rereshRetry2DemoPanel()*/
// if(code1234!=newCode){
// window.frames["iframe1234"].document.write("
");
// window.frames["iframe1234"].document.write(decodeHtml($("textarea#stepcodeTextarea1234").val()));
// window.frames["iframe1234"].document.close();
// $(window.frames["iframe1234"]).load(function(){
// $("#iframe1234").height($("#iframe1234").contents().find("body").height()+showittryitheight);
// });
// code1234 = newCode;
// }
});
$(".tryButton1234").click(function(){
$("#tryDiv1234").show();
$("#stepcodeTextarea1234").focus();
$("#stepcodeTextarea1234").height(200);
$("#iframe1234").height(0);
window.frames["iframe1234"].document.write("
");
window.frames["iframe1234"].document.write(decodeHtml($("textarea#stepcodeTextarea1234").val()));
window.frames["iframe1234"].document.close();
//load和下面的非load必需并存,因为如果代码用到了jquery就必须使用load的方式
$(window.frames["iframe1234"]).load(function(){
$("#iframe1234").height($("#iframe1234").contents().find("body").height()+showittryitheight);
});
$("#iframe1234").height($("#iframe1234").contents().find("body").height()+showittryitheight);
this.scrollIntoView(true);
editor1234.focus();
editor1234.setSize(null, "250");
$("#rendering1234").hide();
$("#rendered1234").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 editor1234 = CodeMirror.fromTextArea(document.getElementById("stepcodeTextarea1234"), {
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);
}
}
});
editor1234.on("change",function(doc){
if(!binded1234){
$(window).bind('beforeunload',function(){
binded1234 = true;
return "xxxx";
});
}
var newCode = doc.getValue();
code1234 = newCode;
$("textarea#stepcodeTextarea1234").val(newCode);
if(alreadyWriteCode1234!=code1234){
lastModifedTime1234 = new Date().getTime();
$("#rendering1234").show();
$("#rendered1234").hide();
}
// alert(doc.getValue());
});
$(".CodeMirror").addClass("form-control");
// var editor1234 = CodeMirror.fromTextArea(, {
// lineNumbers: true,
// styleActiveLine: true,
// matchBrackets: true,
// theme:"eclipse",
// });
editor1234.on("change",function(doc){
// alert(doc.getValue());
});
$("#tryDiv1234").hide();
});
$("div.codemirrorTips span").addClass("glyphicon glyphicon-asterisk");
1. 双击选中单词
2. 三击选中整行
3. CTRL+F 查找
4. F8 全屏编辑,再次点击恢复
|
渲染中
渲染完成
|
get和post的区别
get
是form默认的提交方式
如果通过一个超链访问某个地址,是get方式
如果在地址栏直接输入某个地址,是get方式
提交数据会在浏览器显示出来
不可以用于提交二进制数据,比如上传文件
post
必须在form上通过 method="post" 显示指定
提交数据不会在浏览器显示出来
可以用于提交二进制数据,比如上传文件
代码高亮插件双击即可选中,不过部分同学反应,通过代码高亮插件复制的代码无法在IDEA里正常显示,这里提供TEXTAREA的方式,方便复制,谢谢
1. 自行完成练习
根据练习目标尽量自己实现代码效果,期间会碰到疑问,难题,和自己不懂的地方,这些都是必要的过程
2. 带着疑问查看答案
完成过程中,碰到无法解决的问题,带着疑问,查看答案,分析答案的解决思路
3. 查看答案讲解视频
依然有不明白的地方,点开视频讲解,带着疑问,听视频讲解有问题的部分
4. 再做一遍
理解后,再从头做一遍,把有疑问的地方都捋清楚
5. 总结
最后再总结一遍,总结思路,总结解决办法,以后遇到类似的问题,怎么处理
HOW2J公众号,关注后实时获知布最新的教程和优惠活动,谢谢。
提问之前请登陆
|