I have a follow up question to Can a Jupyter / IPython notebook take arguments in the URL?
There is an assumption here that the HTML object should be the last one in the cell and the print URL is in the next one. Is it possible to get the URL directly without these assumptions? I need it in an app that runs through a package voila. A snippet of code(like below from the other query on stackoverflow) in a single cell would be ideal.
*from IPython.display import HTML HTML(''' <script type="text/javascript"> IPython.notebook.kernel.execute("URL = '" + window.location + "'") </script>''') print(URL)* 1 Answer
you can insert a div and print the url into this div:
from IPython.display import HTML HTML(''' <div></div> <script type="text/javascript"> document.getElementById("url_output").innerHTML = window.location </script> ''') 1