Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- "cells": [
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "import IPython\n",
- "import html\n",
- "\n",
- "raw_html = '''\n",
- "<html>\n",
- "\n",
- "<head>\n",
- "\n",
- "<h1>Some HTML in an iframe</h1>\n",
- "\n",
- "<div id=\"control\">\n",
- " <a href=\"#\"><small>[-]</small></a>\n",
- "</div>\n",
- "\n",
- "</body>\n",
- "</html>\n",
- "\n",
- "'''\n",
- "\n",
- "# In my actual case, this JS runs when the [-] is clicked. It is not necessary to reproduce this issue though.\n",
- "# d3.select(\"#meta_control\").on(\"click\", function() {\n",
- "# d3.select(\"#meta\").style(\"display\", \"none\");\n",
- "# });\n",
- " \n",
- "iframe = f'''<iframe srcdoc=\"{html.escape(raw_html)}\" width=100%% height=250></iframe>'''\n",
- "IPython.display.HTML(iframe)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "with open(\"test.html\", \"w\") as f:\n",
- " f.write(raw_html)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "iframe = '<iframe src=test.html width=100%% height=250></iframe>'\n",
- "IPython.core.display.display(IPython.core.display.HTML(iframe))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": [
- "IPython.core.display.display(IPython.display.IFrame('test.html', width=700, height=250))"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.6.1"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 2
- }
Add Comment
Please, Sign In to add comment