私はJS/Jqueryの全部のノブですので、私に同行してください。私は以下のコードを使用して、ユーザが入力する前に&が自分のサイトのToSに同意することを要求しています。あなたがESCを押すか、ボックスの外側をクリックすると、ポップアップボックスが閉じます。私はこれを防ぐために、サイトにアクセスするためにAgreeボタンをクリックする必要があります。 (私のコード例では、ちょうど 'ddd')どんな助けもありがとう。まあhttps://jsfiddle.net/gzx342xy/ウィンドウの外側をクリックしてJqueryのポップアップを閉じるのを防ぐ
jQuery(document).ready(function(){
jQuery('a.agree-accept').click(function(){
jQuery('#popup-container-box').fadeOut();
jQuery('#active-popup-box').fadeOut();
});
var visits = jQuery.cookie('visits') || 0;
visits++;
jQuery.cookie('visits', visits, { expires: 0, path: '/' });
console.debug(jQuery.cookie('visits'));
if (jQuery.cookie('visits') > 1) {
jQuery('#active-popup-box').hide();
jQuery('#popup-container-box').hide();
} else {
var pageHeight = jQuery(document).height();
jQuery('<div id="active-popup-box"></div>').insertBefore('body');
jQuery('#active-popup-box').css("height", pageHeight);
jQuery('#popup-container-box').show();
}
if (jQuery.cookie('noShowWelcome')) { jQuery('#popup-container-box').hide(); jQuery('#active-popup-box').hide(); }
});
jQuery(document).mouseup(function(e){
var container = jQuery('#popup-container-box');
if(!container.is(e.target)&& container.has(e.target).length === 0)
{
container.fadeOut();
jQuery('#active-popup-box').fadeOut();
}
});
#active-popup-box {
background-color: rgba(0,0,0,0.5);
position: absolute;
width: 100vw;
height: 100vh;
top: 0;
left: 0;
z-index: 9999999999;
}
#popup-container-box {
left: 0;
right: 0;
top: 0;
bottom: 0;
margin: auto;
position: fixed;
width: 100px;
height: 100px;
background-color: #fff;
z-index: 99999999999;
display: none;
}
.modal-content-box {
position: relative;
text-align: center;
}
#popup-window-box { position: relative; }
a.agree-accept {
position:relative;
width: 25px!important;
float: right!important;
-webkit-transition: all 400ms ease-in-out;
transition: all 400ms ease-in-out;
background: transparent!important;
color: #555555!important;
border: none!important;
font-size: 35px!important;
padding: 0!important;
outline: 0;
cursor:pointer;
z-index: 99999;
}
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://s3-us-west-2.amazonaws.com/bridgeconf2015/js/jquery.cookie.js"></script>
<div id="popup-container-box">
<a class="agree-accept">X</a>
<div id="popup-window-box animate slideInUp">
</div>
</div>
フェードアウトしません
で行うコード? http://jqueryui.com/dialog/#modal-confirmation –