如何解决Simple Modal 将刷新页面 SP Online (2013)
我有下面的代码,但我无法正常工作。
<html>
<head>
<meta name="viewport" content="width=device-width,initial-scale=1">
<style>
body {font-family: Arial,Helvetica,sans-serif;}
/* The Modal (background) */
.modal {
display: none; /* Hidden by default */
position: fixed; /* Stay in place */
z-index: 1; /* Sit on top */
padding-top: 100px; /* Location of the box */
left: 0;
top: 0;
width: 100%; /* Full width */
height: 100%; /* Full height */
overflow: auto; /* Enable scroll if needed */
background-color: rgb(0,0); /* Fallback color */
background-color: rgba(0,0.4); /* Black w/ opacity */
}
/* Modal Content */
.modal-content {
background-color: #fefefe;
margin: auto;
padding: 20px;
border: 1px solid #888;
width: 90%;
height: 90%;
}
/* The Close Button */
.close {
color: #aaaaaa;
float: right;
font-size: 28px;
font-weight: bold;
}
.close:hover,.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
.flip-card {
background-color: transparent;
width: 200px;
height: 200px;
perspective: 1000px;
float: right;
margin: 1em;
}
.flip-card-inner {
position: relative;
width: 100%;
height: 100%;
text-align: center;
transition: transform 0.6s;
transform-style: preserve-3d;
box-shadow: 0 4px 8px 0 rgba(0,0.2);
}
.flip-card:hover .flip-card-inner {
transform: rotateY(180deg);
}
.flip-card-front,.flip-card-back {
position: absolute;
width: 100%;
height: 100%;
-webkit-backface-visibility: hidden;
backface-visibility: hidden;
float: right;
}
.flip-card-front {
background-color: #98D0F0;
color: black;
width:200px;
height:200px;
}
.flip-card-back {
background-color: #98BBF0;
color: white;
transform: rotateY(180deg);
width:200px;height:200px;
}
.card {
background-color: transparent;
width: 200px;
height: 200px;
perspective: 1000px;
float: left;
margin: 1em;
}
</style>
</head>
<body>
<h2>Modal Example</h2>
<!-- Trigger/Open The Modal -->
<button id="myBtn">
<div class="card">
<p>CERT Services</p>
</div>
</button>
<!-- The Modal -->
<div id="myModal" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
</div>
<div class="flip-card-back">
</div>
</div>
</div>
<!-- another one-->
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
<h3>Service Name</h3>
</div>
<div class="flip-card-back">
<p>description</p>
</div>
</div>
</div>
<!-- end-->
<!-- another one-->
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
</div>
<div class="flip-card-back">
</div>
</div>
</div>
<!-- end-->
<!-- another one-->
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
</div>
<div class="flip-card-back">
</div>
</div>
</div>
<!-- end-->
</div>
<!-- NEW MODAL-->
<div id="myModal-2" class="modal">
<!-- Modal content -->
<div class="modal-content">
<span class="close">×</span>
<div class="flip-card">
<div class="flip-card-inner">
<div class="flip-card-front">
</div>
<div class="flip-card-back">
</div>
</div>
</div>
</div>
</div>
<script>
// Get the modal
var modal = document.getElementById("myModal");
// Get the button that opens the modal
var btn = document.getElementById("myBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];
// When the user clicks the button,open the modal
btn.onclick = function() {
modal.style.display = "block";
}
// When the user clicks on <span> (x),close the modal
span.onclick = function() {
modal.style.display = "none";
}
// When the user clicks anywhere outside of the modal,close it
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
</body>
</html>
我厌倦了修复它,但我想我缺乏技能。我使用脚本编辑器在我的 SP 页面上传。我点击它的那一刻,它会显示模式框,几秒钟后它会刷新页面。
我该如何修复它,购买而不使其刷新?它应该保持打开状态,直到我点击“x”按钮。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。