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?
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?
Share Improve this question asked Mar 23, 2012 at 9:36 Xiaodan MaoXiaodan Mao 1,7062 gold badges17 silver badges32 bronze badges 3- where is this method defined (showModalDialog), are you using a library maybe ? – Tom Commented Mar 23, 2012 at 10:25
- 1 This is very basic JavaScript, I hardly believe you couldn't find any documentation on the subject. For instance – Madara's Ghost Commented Mar 23, 2012 at 10:45
- 1 Yeah,you are right,you make me feel ashamed,self thinking is needed. – Xiaodan Mao Commented Mar 25, 2012 at 13:00
1 Answer
Reset to default 13Following 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>