iframe not rendering in ipython-notebook

左心房为你撑大大i 提交于 2019-11-28 00:22:55

问题


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?


回答1:


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.




回答2:


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.




回答3:


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


来源:https://stackoverflow.com/questions/17619964/iframe-not-rendering-in-ipython-notebook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!