Reputation: 964
I'm trying to open an html file in a new browser tab in Jupyterlab. The jupyterLab that I'm working on is hosted in a container remotely.
The solution that I already tried are:
Using html tag
'< a href="./docs/index.html" target="_blank"> Docs < / a>'
This works fine with Jupyter, but when I run it on jupyterLab, I got the file get opened in jupyter tab (not browser tab)
import webbrowser, os
webbrowser.open('file:///' + os.path.realpath("docs/yenko/index.html"))
This solution also works fine in Jupyter notebook, but when I tried jupyterLab, I got false as output
from IPython.display import IFrame
IFrame(src="docs/yenko/index.html", width='100%', height='1000px')
This solution works fine, but I kept it as alternative. Currently I'm looking to display the content in new browser tab, not inside the notebook.
Any suggestions?
Upvotes: 1
Views: 3460
Reputation: 137
In Jupyterlab an href to an external link like
<a href="https://stackoverflow.com">test ext html</a>
opens in a new tab of the browser, both in markdown and in a code cell with magic %%html
you can try creating a shared folder and writing the (usual) href
s of your local html
files with their full network path to see if jupyterlab doesn't interpret them as local
note:
normally, in jupyterlab, markdown cells render local links changing the actual href of, say, test.html
into
http://localhost:8888/files/test.html
adding actually many more attributes to <a>
on rendering, you can see this inspecting the jupyterlab's webpage (ctrl+shift+i
in chrome)
Upvotes: 1