Previously,I used the window.showModalDialog() function to popup a window:
window.showModalDialog("myHtml")
In myHtml,there are some html elements,like the textarea and two buttons. But now the situation changed,any html file is not allowed.So I have to create the html elements dynamically in the popup window.Is it possible?
Following code works for me:
<script type="text/javascript">
function createPopup(){
var popup = open("", "Popup", "width=300,height=200");
var txtOk = popup.document.createElement("TEXTAREA");
var aOk = popup.document.createElement("a");
aOk.innerHTML = "Click here";
popup.document.body.appendChild(txtOk);
popup.document.body.appendChild(aOk);
}
</script>
To call, use:
<div id="divPopup" onclick="createPopup();">Create popup</div>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With