Skip to main content

Posts

Showing posts from May, 2017

Modal dialog window using Javascript and CSS

Add this function to your scripts. Call it from a click or other events like button.onlick= function() { showModal("some content to be shown as modal dialog"); function showModal(txt) {     var d = document.getElementById("xf_modal_window"); d && n.parentNode.removeChild(d); var n = document.createElement("div");     n.id = "xf_modal_window", n.className = "modal"; var o = document.createElement("div");     o.id = "er_div_modal_content", o.innerHTML = txt, n.appendChild(o); var t = document.createElement("input");     t.type = "BUTTON", t.value = "close", t.onclick = function () { t.parentNode.parentNode.removeChild(n) }, n.appendChild(t), document.body.appendChild(n) } This to your CSS  .modal {     position: absolute;     left: 0px;     top: 0px;     width: 100%;     height: 100%;     text-align: center;     z-index: 990;     background-color: #808080;