Hello following is my div of modal. when I open the modal without this piece of code document.write( webcam.get_html(320, 240) ); then the modal opens up successfully but when i put the above mentioned code then it opens up the new page and shows the document.write content into that page. Kindly let me know how can i modify the following div so it shows the document.write( webcam.get_html(320, 240) ); inside the modal. webcam.get_html(320, 240) is a command of jpegcam plugin that runs the webcam of the laptop or the like, I also even tried by putting simple text document.write( "abcd"); and on opening the modal it shows abcd on new page. Kindly help, Thanks,

<div style='display:none' id="modal-content">
     <script language="JavaScript">
        document.write( webcam.get_html(320, 240) );
    </script>
</div>
有帮助吗?

解决方案

You shoud use something other than document.write, like getting the actual element you're trying to add content to, and the insert the HTML into that :

document.getElementById('modal-content').innerHTML = 'stuff to add here';

jQuery version:

$('#modal-content').html('stuff to add here');

其他提示

 document.getElementById('modal-content').innerHTML = 'stuff to add here';
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top