From 713bed70696d84d99e2b61bf2083450209472def Mon Sep 17 00:00:00 2001 From: Jacob Weisz Date: Fri, 7 Oct 2022 02:35:17 -0500 Subject: [PATCH] Docs: Add JS to target external links --- docs/developing/troubleshooting.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/docs/developing/troubleshooting.md b/docs/developing/troubleshooting.md index b5b71bee..a2716568 100644 --- a/docs/developing/troubleshooting.md +++ b/docs/developing/troubleshooting.md @@ -22,7 +22,7 @@ docs about the `vagrant-spk enter-grain` command](debugging.md). ## Clicking a link in the app does not open the link Sandstorm apps cannot navigate the user away from the app. Therefore, app -authors should set `target="_blank"` on links within the app. +authors should set `target="_blank"` on external links within the app. A convenient way to do this automatically for all links in the page is to add the following HTML to your document's ``: @@ -31,6 +31,20 @@ the following HTML to your document's ``: ``` +However, if you have both internal and external links, you can add a script +such as the following which will only set the target on external links: + +```js +window.onload = function(){ + var a = document.getElementsByTagName('a'); + for (var i=0; i