js弹出框、对话框、提示框、弹窗总结
2020-08-19 10:21
https://www.cnblogs.com/lstory/p/7473991.html
一、js的三种最常见的对话框
1 //====================== JS最常用三种弹出对话框 ======================== 2 3 //弹出对话框并输出一段提示信息 4 function ale() { 5 //弹出一个对话框 6 ; 7 8 } 9 10 //弹出一个询问框,有确定和取消按钮 11 function firm() { 12 //利用对话框返回的值 (true 或者 false) 13 if (confirm("你确定提交吗?")) { 14 ; 15 } 16 else { 17 ; 18 } 19 20 } 21 22 //弹出一个输入框,输入一段文字,可以提交 23 function prom() { 24 var name = prompt("请输入您的名字", ""); //将输入的内容赋给变量 name , 25 26 //这里需要注意的是,prompt有两个参数,前面是提示的话,后面是当对话框出来后,在对话框里的默认值 27 if (name)//如果返回的有内容 28 { 29 30 } 31 32 }
二、点击按钮时常用的6中提示框和操作
1 [html] view plain copy 2 3 <input type="button" name="btn2" id="btn2" value="删除" "color: rgb(0, 0, 255);">="return confirm('Yes/No');); 4 5 6 ="btn2" id="btn2" value="提示" "color: rgb(0, 0, 255);">="; 7 8 9 ="提交" "color: rgb(0, 0, 255);">=".href='http://www.baidu.com';"/> 10 11 12 <input type="button" value="关闭" "color: rgb(0, 0, 255);">="close();"> 13 14 15 <a href="#" "color: rgb(0, 0, 255);">=";opener.reload();close()">返回a> 16 .reload();//返回当前页并刷新 17 18 19 <input type="button" name="button" value="< 返回" "color: rgb(0, 0, 255);">="history.go(-1)"/> 20
三、弹出独立窗口
1 [javascript] view plain copy
2 //关闭,父窗口弹出对话框,子窗口直接关闭
3 this.Response.Write("");
33
34 //弹出相同的一页
35
36
37 //
38 Response.Write("parent.mainFrameBottom.href='yourwebform.aspx?temp=" +str+"';");
39
40
41