html - Is it possible to create an iframe on click of a button using javascript -


I have a UI with a print button, I want to create an iframe when I click on the print button, is it possible Is javascript?

  document.getElementById ('print-button'). Onclick = function () {var iframe = document.createElement ('iframe'); Iframe.src = 'http://example.com'; Document.body.appendChild (iframe); };   

Of course, if you want to attach more events of the same type, then use addEventListener () .

If click on jQuery (function () {$ ("& lt; iframe / & gt;", {src: "http: / /example.com"}). Attachment ("body ");});

Comments