layer弹出层
最近因为项目要求做了一个layer弹出层demo,先看效果图
好了,现在开始上代码
index.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <! DOCTYPE HTML> < html > < head > < base href="<%=basePath%>"> < title >My JSP 'index.jsp' starting page</ title > <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </ head > < body > < input type="button" onclick="openFirstLayer()" value="点击"/> < script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></ script > < script type="text/javascript" src="layer/layer.js"></ script > < script type="text/javascript"> function openFirstLayer(){ /* layer.open({ type: 2, title: ['你好','background-color:red,padding-left:5px'], closeBtn: 1, //显示关闭按钮 shade: [0.3], area: ['500px', '400px'], offset: 'r', //右下角弹出, move: false, //anim: 4, content: ['test.jsp', 'no'] //iframe的url,no代表不显示滚动条 }); */ layer.open({ type: 2, title: ['历史进度展示','background-color:rgb(40, 144, 241);padding-left:5px;color:#fff'], closeBtn: 1, //显示关闭按钮 shade: [0.3], area: ['50%', '60%'], offset: 'r', //右下角弹出, move: false, //anim: 4, content: ['test.jsp', 'no'] //iframe的url,no代表不显示滚动条 }); } </ script > </ body > </ html > |
test.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <! DOCTYPE HTML> < html > < head > < base href="<%=basePath%>"> < title >My JSP 'test.jsp' starting page</ title > <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </ head > < body > < input type="button" onclick="openSecondLayer()" value="测试"/> < script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></ script > < script type="text/javascript" src="layer/layer.js"></ script > < script type="text/javascript"> function openSecondLayer(){ /* parent.layer.open({ type: 1, skin: 'layui-layer-rim', //加上边框 area: ['420px', '240px'], //宽高 content: 'html内容', cancel: function(index){ if(confirm('确定要关闭么')){ } //return false; } }); */ parent.layer.open({ type: 2, title: ['历史进度详情','background-color:rgb(40, 144, 241);padding-left:5px;color:#fff'], //skin: 'layui-layer-rim', //加上边框 area: ['60%', '80%'], //宽高 content: ['test2.jsp','no'], //iframe的url,no代表不显示滚动条 cancel: function(index){ window.location.href = "test.jsp"; /* if(confirm('确定要关闭么')){ } */ //return false; } }); } </ script > </ body > </ html > |
test2.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <! DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> < html > < head > < base href="<%=basePath%>"> < title >My JSP 'test2.jsp' starting page</ title > < meta http-equiv="pragma" content="no-cache"> < meta http-equiv="cache-control" content="no-cache"> < meta http-equiv="expires" content="0"> < meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> < meta http-equiv="description" content="This is my page"> <!-- <link rel="stylesheet" type="text/css" href="styles.css"> --> </ head > < body > This is my JSP page. < br > </ body > </ html > |
只是一个简单demo展示,剩下的拓展需要自己再去深入挖掘
分类:
前端相关
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix