Open ALL links in new Window phpBB

Post Reply
steven
Posts: 133
Joined: Sun Oct 01, 2017 3:08 pm

Open ALL links in new Window phpBB

Post by steven »

This modification applies to prosilver but may work on other styles depending on how they are written. WARNING: this change opens all links in a new window, even links to pages on your website.

Making this change requires modifying the bbcode.html file. The file is located in the following folder \styles\prosilver\template. Before you change any code make a copy of the file, in case you make a mistake.

Open the bbcode.html file and locate the line containing the code below: (Line 75 in pbpBB 3.3.0)

Code: Select all

<!-- BEGIN url --><!--<a href="{URL}" class="postlink">{DESCRIPTION}</a>--><!-- END url -->
Replace with ONE of the two codes below. The difference is one sends a referring header the other does not :

The code below prevents the linked page from running on the same processes and SENDS the referrer header:

Code: Select all

<!-- BEGIN url --><a href="{URL}" target="_blank" rel="noopener" class="postlink">{DESCRIPTION}</a><!-- END url -->
The code below prevents the linked page from running on the same processes but BLOCKS the referrer header:

Code: Select all

<!-- BEGIN url --><a href="{URL}" target="_blank" rel="noreferrer" class="postlink">{DESCRIPTION}</a><!-- END url -->
After you make the change, log into ACP (Admin Control Panel) and purge the cache so your change takes effect.
 

If you want to open internal links in the same window but external links in a new window, install an extension. I use Prime Links on this website. It has many options for both local and external links so you can configure either local and/or external links to open in a new window. If the Prime Links version on phpBB is not 1.1.7 or greater, you can download it directly from the authors website.

Settings for LOCAL links are:
Set Link target to _self (Opens in the same window)
Set Link target to _blank (Opens a new window)

Settings for EXTERNAL links are:
Set Link target to _self (Opens in the same window)
Set Link target to _blank (Opens a new window)

If you use _blank for external links, set the link relationship as follows:
Either set Link relationship to noopener to prevent access to window.open and send the referrer header,
or set Link relationship to noreferrer to prevent access to window.open and blocks sending the referrer header.

Failure to use either noopener or noreferrer for external links allows access to processes running on your page, which is never good.
If you are unsure which settings to use click here for more info.
Post Reply