Request // Configuration option for page content links to open in _blank #799

Closed
opened 2026-02-04 22:19:14 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @derek-shnosh on GitHub (Aug 29, 2018).

Describe the feature you'd like
I'd like to be able to configure how links within page content are opened, or at the very least have them open in _blank instead of _parent as they do now.

I'm used to ctrl-clicking links on other sites to accomplish this, but I think what's throwing me off with BookStack is that attachment links open in _blank but links in the page content do not.

By the way, if someone has a way to accomplish this with custom HTML that will affect pages only, I'm all ears.

Additional context
Maybe this (and other) configuration options can be globally defined and pages can have a configuration area to set their local preference; i.e. for options that may be relevant at a page level. These options would ideally be accessed behind a gear icon similar to how tags are manipulated when editing a page.

Who knows, maybe this page config panel could prove useful for other page level configuration options/flags that may be implemented in the future.

Originally created by @derek-shnosh on GitHub (Aug 29, 2018). **Describe the feature you'd like** I'd like to be able to configure how links within page content are opened, or at the very least have them open in `_blank` instead of `_parent` as they do now. I'm used to _ctrl-clicking_ links on other sites to accomplish this, but I think what's throwing me off with BookStack is that attachment links open in `_blank` but links in the page content do not. By the way, if someone has a way to accomplish this with custom HTML that will affect _pages **only**_, I'm all ears. **Additional context** Maybe this (and other) configuration options can be globally defined and pages can have a configuration area to set their local preference; i.e. for options that may be relevant at a page level. These options would ideally be accessed behind a _gear_ icon similar to how tags are manipulated when editing a page. Who knows, maybe this page config panel could prove useful for other page level configuration options/flags that may be implemented in the future.
OVERLORD added the Open to discussion label 2026-02-04 22:19:14 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Aug 29, 2018):

Hi @derek-shnosh,
You can use the following in the custom head HTML:

<script>
	document.addEventListener('DOMContentLoaded', function() {
		var links = document.querySelectorAll('.page-content a');
		for (var i = 0; i < links.length; i++) {
			links[i].target = '_blank';
		}
	});
</script>

Should work down to IE9.

I'm generally hesitant to layer in more and more options, Especially if granular and/or ones that require additional UI. Will leave this open for discussion though.

@ssddanbrown commented on GitHub (Aug 29, 2018): Hi @derek-shnosh, You can use the following in the custom head HTML: ```html <script> document.addEventListener('DOMContentLoaded', function() { var links = document.querySelectorAll('.page-content a'); for (var i = 0; i < links.length; i++) { links[i].target = '_blank'; } }); </script> ``` Should work down to IE9. I'm generally hesitant to layer in more and more options, Especially if granular and/or ones that require additional UI. Will leave this open for discussion though.
Author
Owner

@derek-shnosh commented on GitHub (Aug 29, 2018):

The script worked great, thanks!

I completely understand your apprehension to configuration-paralysis, there's a fine line between customizability and overwhelming buttons and knobs.

@derek-shnosh commented on GitHub (Aug 29, 2018): The script worked great, thanks! I completely understand your apprehension to configuration-paralysis, there's a fine line between customizability and overwhelming buttons and knobs.
Author
Owner

@Kdecherf commented on GitHub (Sep 3, 2018):

Hello there,

Here is a side-note on the security of _blank links: https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/

@Kdecherf commented on GitHub (Sep 3, 2018): Hello there, Here is a side-note on the security of `_blank` links: https://www.jitbit.com/alexblog/256-targetblank---the-most-underestimated-vulnerability-ever/
Author
Owner

@derek-shnosh commented on GitHub (Sep 21, 2018):

Thanks @Kdecherf, I stumbled upon that thread, and others, when searching how to accomplish this on my own (before @ssddanbrown provided a script).

At the time I was a bit blind/deaf to the concerns, but after going over it all again I've decided to revert to the default behavior.

@ssddanbrown, that being said... I'm wondering what your thoughts on external link attachments are? i.e. whether or not they should go to _blank as they do now.

@derek-shnosh commented on GitHub (Sep 21, 2018): Thanks @Kdecherf, I stumbled upon that thread, and others, when searching how to accomplish this on my own (before @ssddanbrown provided a script). At the time I was a bit blind/deaf to the concerns, but after going over it all again I've decided to revert to the default behavior. @ssddanbrown, that being said... I'm wondering what your thoughts on external link attachments are? i.e. whether or not they should go to `_blank` as they do now.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#799