diff --git a/_includes/scripts/misc.liquid b/_includes/scripts/misc.liquid index 61223b17acf4..07b117e46990 100644 --- a/_includes/scripts/misc.liquid +++ b/_includes/scripts/misc.liquid @@ -31,3 +31,6 @@ + + + diff --git a/assets/js/jupyter_new_tab.js b/assets/js/jupyter_new_tab.js new file mode 100644 index 000000000000..4098af66edd5 --- /dev/null +++ b/assets/js/jupyter_new_tab.js @@ -0,0 +1,18 @@ +$(document).ready(function () { + // Let external links in jupyter notebooks open in new tab + let jupyterNotebooks = $(".jupyter-notebook-iframe-container"); + jupyterNotebooks.each(function () { + let iframeBody = $(this).find("iframe").get(0).contentWindow.document.body; + // Get all elements in the bodyElement + let links = $(iframeBody).find("a"); + + // Loop through each element + links.each(function () { + // Check if the element has an 'href' attribute + if ($(this).attr("href")) { + // Set the 'target' attribute to '_blank' to open the link in a new tab/window + $(this).attr("target", "_blank"); + } + }); + }); +});