¿Es posible abrir una nueva ventana e incrustar iframe en esto?

I need to open a new window and I want to embed a video in an iframe and show it in this window. As normal pop-up window syntax is:


How will I pass the iframe code instead of URL so that the iframe is embedded in the new window? Please suggest.

Gracias de antemano.

preguntado el 27 de noviembre de 13 a las 06:11

1 Respuestas

You don't pass the iframe code to window.open, you get a handle on the window you are opening and write the iframe to that window.

var win = window.open();
win.document.write('<iframe width="560" height="315" src="//www.youtube.com/embed/mTWfqi3-3qU" frameborder="0" allowfullscreen></iframe>')

respondido 27 nov., 13:07

I want same functionality with PDF doc I just replace the src with pdf content but not working - Abdul Hamid

@AbdulHameed you want the pdf in an iframe inside the pop up window? If so, it should work the same as the YouTube link in the iframe, I suggest checking that the path to the pdf file is correct - Rob M.

var string = doc.output('datauristring'); var iframe = "<iframe width='100%' height='100%' src='" + string + "'></iframe>" var x = window.open(); x.document.open(); x.document.write(iframe); x.document.close(); //Use this @AbdulHameed - Joyston

window.open() currently returns null on Chrome so your provided solution is obselete - Necroqubus

@Necroqubus not sure which version of Chrome you are running, but it works fine on the current version - Version 70.0.3538.110 (Official Build) (64-bit) - Rob M.

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.