From 1586e3ec7094f17e115c0f903d4f0d91a0b5efa2 Mon Sep 17 00:00:00 2001 From: hoseppan Date: Tue, 24 Sep 2019 09:59:55 -0700 Subject: [PATCH] Open url (#607) --- examples/user_guide/Links.ipynb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/user_guide/Links.ipynb b/examples/user_guide/Links.ipynb index e67062f03a..6b1c2ccbc1 100644 --- a/examples/user_guide/Links.ipynb +++ b/examples/user_guide/Links.ipynb @@ -352,6 +352,27 @@ "text_input.value=\"Markdown display\"" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "#### Open URL\n", + "\n", + "As an example of using `jslink`, here we open a URL from the ``TextInput`` widget value. A new browser tab will open with the provided URL:" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "button = pn.widgets.Button(name='Open URL', button_type = 'primary')\n", + "url = pn.widgets.TextInput(name='URL', value = 'https://pyviz.org/')\n", + "button.jslink(url, code={'clicks': 'window.open(target.value)'})\n", + "pn.Row(url, button)" + ] + }, { "cell_type": "markdown", "metadata": {},