Links to Documents - Where They Open Up at

Jason76

Madly Diligent
Joined
Nov 27, 2016
Messages
7,210
Reaction score
960
FP$
575
On my drum lesson site, the links to pdf files open in the same window. However, people might prefer a different window. What do you think most people want? What do you like? How can bbCode be manipulated to make the pdf files open in a different window?
 
I rather have all links that are posted to open on another windows tab rather then making the page to reload. 90% of the time I go back to the topic anyway if it does make the page to reload to the link that you have clicked on.
 
If your BBCode editor supports HTML attributes, then all you need to add to your .pdf link is the `target="_blank"` attribute. Like so:
Code:
[a href="#" target="_blank"]Link text[/a]

If not, you could write a script that appends this attribute to all links that end in .pdf:

jQuery:
Code:
$('a[href$=".pdf"]').attr('target', '_blank');
Vanilla:
Code:
let link = document.querySelector('a[href$=".pdf"]');
link.setAttribute('target', '_blank');

However, you might consider the points made about opening links in a new tab from this CSS Tricks article:

https://css-tricks.com/use-target_blank/
 
I mean XenForo software.

https://xenforo.com/community/help/bb-codes/

If your BBCode editor supports HTML attributes, then all you need to add to your .pdf link is the `target="_blank"` attribute. Like so:
Code:
[a href="#" target="_blank"]Link text[/a]

If not, you could write a script that appends this attribute to all links that end in .pdf:

jQuery:
Code:
$('a[href$=".pdf"]').attr('target', '_blank');
Vanilla:
Code:
let link = document.querySelector('a[href$=".pdf"]');
link.setAttribute('target', '_blank');

However, you might consider the points made about opening links in a new tab from this CSS Tricks article:

https://css-tricks.com/use-target_blank/

I will try that.
 
Back
Top Bottom