我怎么能关闭这个弹出窗口?在这段代码中,我打开一个弹出窗口,在另一个页面中显示一些代码。我需要一个按钮来关闭此弹出窗口。
<script type="text/javascript">
var xmlhttp;
function showpopup(id) {
document.getElementById('popup').style.display = 'block';
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
}
else { // code for IE6, IE5
xmlhttp = new ActiveXObject('Microsoft.XMLHTTP');
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
document.getElementById('response').innerHTML = xmlhttp.responseText;
}
};
xmlhttp.open('GET', 'more-messages.php?id=' + id, true);
xmlhttp.send();
}
</script>
<a href='#' onclick=\"showpopup($id)\">link to ID</a>
<div id='popup' style='background-color: #888888; position: absolute; top: 0; left: 0; opacity: 0.4; display: none; width: 100%; height: 100%'>
</div>
<div id='response' style='position: absolute; top: 0; left: 0; width: 40%; margin-top: 14.5%; margin-left: 30%; border: 1px solid balck; background-color: #ffffff; border-radius: 25px;'>
</div>