以下是使用JSP和JavaScript实现您要求的代码:
<!DOCTYPE html>
<html>
<head>
<title>弹框示例</title>
<script type="text/javascript">
window.onload = function() {
var popup = document.getElementById("popup");
popup.style.display = "block";
}
function closePopup() {
var popup = document.getElementById("popup");
popup.style.display = "none";
}
</script>
<style type="text/css">
.popup {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
background-color: #ffffff;
border: 1px solid #cccccc;
padding: 20px;
display: none;
}
.popup button {
background-color: #4CAF50;
color: #ffffff;
border: none;
padding: 10px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 16px;
margin: 4px 2px;
cursor: pointer;
float: right;
}
</style>
</head>
<body>
<div id="popup" class="popup">
<p>我10:00-10:30 11:00-11:30 开会,来找我的话麻烦避开这两个时间段,另外,不提交作业的话视为当天没有完成作业,每月底评价前我会提交记录给部长。</p>
<button οnclick="closePopup()">确认</button>
</div>
</body>
</html>
解释一下以上代码的功能:
- 首先使用HTML和CSS创建一个弹框,它被设置为初始状态下不可见。
- 在JavaScript中,当页面加载时会调用window.onload函数来显示弹框。
- 当用户点击确认按钮时,调用closePopup函数来隐藏弹框。
请注意,以上示例只是实现了基本的弹框显示和关闭功能,您需要根据自己的需求进行修改和扩展。