Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iframe not rendering in ipython-notebook

The following iframe will not render in an ipython-notebook

from IPython.display import HTML
HTML('<iframe src=http://stackoverflow.com width=700 height=350></iframe>')

but, this one will render (note, .com versus .org)

from IPython.display import HTML
HTML('<iframe src=http://stackoverflow.org width=700 height=350></iframe>')

Is there something I am doing wrong in the first example? If this is a bug, where do I submit a bug report?

like image 638
Julien Chastang Avatar asked Jul 12 '13 16:07

Julien Chastang


3 Answers

IPython now supports IFrame directly:

from IPython.display import IFrame
IFrame('http://stackoverflow.org', width=700, height=350)

For more on IPython embeds check out this IPython notebook.

like image 65
zach Avatar answered Nov 20 '22 10:11

zach


You have a "Refused to display document because display forbidden by X-Frame-Options." in javascript console. Some sites explicitly refuse to be displayed in iframes.

like image 10
Matt Avatar answered Nov 20 '22 10:11

Matt


I was able to get some iframes to embed on my notebook server by modifying the url to use https:

from IPython.display import VimeoVideo
v = VimeoVideo(id='53051817', width=800, height=600)
print v.src
>>> 'http://player.vimeo.com/video/53051817'
v.src = v.src.replace('http','https')
v
like image 1
kelorek Avatar answered Nov 20 '22 11:11

kelorek