I'm trying to open or close a SharePoint Modal Dialog. The dialog opens one time, but it doesn't open in the second time, I just get a weird title only box. Also I cannot figure out how to close the dialog programmatically. Here is my code.
<button type=button onclick="openDialog()">click me</button>
<div id="wrap" style="display:none">
<div id="d10">
my dialog message
<button type=button onclick="closeDialog()">OK</button>
</div>
</div>
<script>
function openDialog() {
var e = document.getElementById('d10');
var options = {
title: "My Dialog Title",
width: 400,
height: 300,
html: e
};
SP.UI.ModalDialog.showModalDialog(options);
}
function closeDialog() {
// HOW DO I CLOSE IT?!
}
</script>