다음 코드로 iframe poup을 만들었습니다. 팝업은 iframe 콘텐츠와 함께로드됩니다. 그러나 닫기 버튼이 없습니다.
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript">
$(function() {
//----- OPEN
$('[data-iframe-open]').on('click', function(e) {
var targeted_popup_class = jQuery('[data-iframe-open]').attr('data-iframe-open');
$('[data-iframe="' + targeted_popup_class + '"]').fadeIn(500);
e.preventDefault();
});
//----- CLOSE
$('[iframe-close]').on('click', function(e) {
var targeted_popup_class = jQuery(this).attr('iframe-close');
$('[data-iframe="' + targeted_popup_class + '"]').fadeOut(500);
e.preventDefault();
});
});
</script>
<link rel="stylesheet" type="text/css" href="css/styles.css">
</head>
<body>
<a class="btn" data-iframe-open="popup-1" href="javascript:void(0)">click here</a>
<div class="popup" data-iframe="popup-1">
<div class="popup-inner">
<iframe src="https://jquery.com/" width="100%" height="100%" />
<a class="iframe-close" data-iframe-close="popup-1" href="#">x</a>
</div>
</div>
</body>
</html>
여기 내 CSS가 있습니다.
/* Close Button */
.popup-close {
width:30px;
height:26px;
padding-top:4px;
display:inline-block;
position:absolute;
top:0px;
right:0px;
transition:ease 0.25s all;
-webkit-transform:translate(50%, -50%);
transform:translate(50%, -50%);
border-radius:1000px;
font-family:Arial, Sans-Serif;
font-size:20px;
text-align:center;
line-height:100%;
color:#fff;
text-decoration: none;
background: #DD3535;
}
.popup-close:hover {
-webkit-transform:translate(50%, -50%) rotate(180deg);
transform:translate(50%, -50%) rotate(180deg);
text-decoration:none;
}
html 콘텐츠로 시도하면 모든 것이 잘 작동합니다. http://i.prntscr.com/G3YeTkSqRr2tRFsNIWJqEw.png
iframe 팝업을 어떻게 닫을 수 있습니까?
iframe
태그를 닫습니다 .
<iframe src="https://jquery.com/" width="100%" height="100%" ></iframe>
다음 close
과 같이 기능을 변경하십시오 .
//----- CLOSE
$('.iframe-close').on('click', function(e) {
var targeted_popup_class = jQuery(this).data('iframe-close');
$('[data-iframe="' + targeted_popup_class + '"]').fadeOut(500);
e.preventDefault();
});
이 코드를 이전 코드와 비교하면 차이점을 찾을 수 있습니다.
닫기 버튼 스타일의 변화를 가져올하기 popup-close
에 iframe-close
당신에 CSS
.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다