Как сделать ссылку закрывающую модальное окно?

D
На сайте с 01.09.2015
Offline
59
237

Здравствуйте. Помогите добавить ссылку закрывания модального окна, которая будет располагаться внутри самого окна.


<button onclick="show('block')">Открыть окно</button>

<div onclick="show('none')" id="wrap9"></div>
<div id="window9">
Содержимое окна
</div>


function move() {
slides[index].style.opacity = "";
slides[index].style.zIndex = "";
index = (index + dir + len) % len;
slides[index].style.opacity = 1;
slides[index].style.zIndex = 1;
var article = slides[index].getElementsByTagName('article')[0];
document.getElementById('window9').style.width = article.offsetWidth+'px';
document.getElementById('window9').style.height = article.offsetHeight+'px';
index < len - 1 && (timer = window.setTimeout(move, 1000));
}

function show(state) {
if (state === "block") {
timer = window.setTimeout(move, 0);
} else {
clearTimeout(timer);
}
document.getElementById('window9').style.display = state;
document.getElementById('wrap9').style.display = state;

}


#wrap9{
display: none;
opacity: 0.5;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
background-color: rgba(255, 255, 255, 1);
z-index: 100;
overflow: auto;
}

#window9{
width: 500px;
height: 300px;
margin: auto;
display: none;
background: #fff;
border: 1px solid #365E97;
z-index: 200;
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
padding: 15px 30px 30px 30px;
vertical-align:middle;
-webkit-box-shadow:0 5px 15px rgba(0,0,0,.5);
box-shadow:0 5px 15px rgba(0,0,0,.5);
}
ArbNet
На сайте с 27.10.2019
Offline
125
#1


<a href=# onclick="show('none')">Закрыть</a>

Оно и так закрывается если просто кликнуть на странице вне этого окна.

Обсуждение разработки на моём фреймворке https://discord.gg/23N4s9x2kp
O
На сайте с 30.09.2019
Offline
18
#2

https://jsfiddle.net/km9fgxu4/

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий