Testing open in new window/tab modification

Testing area for the DBB members and staff!
Post Reply
User avatar
KoolBear
DBB Co-Founder
DBB Co-Founder
Posts: 10132
Joined: Thu Nov 05, 1998 12:01 pm
Location: Houston, TX USA
Contact:

Testing open in new window/tab modification

Post by KoolBear »

http://www.KoolBear.com" onclick="window.open(this.href);return false; if mod works link should open in a new window or tab.
User avatar
Spidey
DBB Grand Master
DBB Grand Master
Posts: 10808
Joined: Thu Jun 28, 2001 2:01 am
Location: Earth

Re: Testing open in new window/tab modification

Post by Spidey »

Opened in new window.

IE
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7737
Joined: Mon Aug 01, 2005 8:47 am
Location: 🍕

Re: Testing open in new window/tab modification

Post by Isaac »

Opened in a new tab. Chrome 9.0.597.84 Linux
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-★ ·:*¨༺꧁༺ :E ༻꧂༻¨*:·.★-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
User avatar
KoolBear
DBB Co-Founder
DBB Co-Founder
Posts: 10132
Joined: Thu Nov 05, 1998 12:01 pm
Location: Houston, TX USA
Contact:

Re: Testing open in new window/tab modification

Post by KoolBear »

The forums should open in a new window or tab too.

Any other links that we think should open in a new window please point them out. I know I need to get the BBCode link this is the link that shows up within the Post Topic page. Man that's a frustrating one to hit while you are editing :)
User avatar
Isaac
DBB Artist
DBB Artist
Posts: 7737
Joined: Mon Aug 01, 2005 8:47 am
Location: 🍕

Re: Testing open in new window/tab modification

Post by Isaac »

This feature is one of my favorite things about this forum. Just about all the others I use don't have this.
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-★ ·:*¨༺꧁༺ :E ༻꧂༻¨*:·.★-⎽__⎽-⎻⎺⎺⎻-⎽__⎽--⎻⎺⎺⎻-
❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉❉⊱•═•⊰❉⊱•═•⊰❉⊱•═•⊰❉
User avatar
fliptw
DBB DemiGod
DBB DemiGod
Posts: 6459
Joined: Sat Oct 24, 1998 2:01 am
Location: Calgary Alberta Canada

Re: Testing open in new window/tab modification

Post by fliptw »

why are you using javascript? target="_blank" will work
User avatar
KoolBear
DBB Co-Founder
DBB Co-Founder
Posts: 10132
Joined: Thu Nov 05, 1998 12:01 pm
Location: Houston, TX USA
Contact:

Re: Testing open in new window/tab modification

Post by KoolBear »

I'm not doing anything it's the way phpbb is assembling the url it in the program... and obviously I'm not a programmer. :D
User avatar
KoolBear
DBB Co-Founder
DBB Co-Founder
Posts: 10132
Joined: Thu Nov 05, 1998 12:01 pm
Location: Houston, TX USA
Contact:

Re: Testing open in new window/tab modification

Post by KoolBear »

Isaac wrote:This feature is one of my favorite things about this forum. Just about all the others I use don't have this.
lol, that;s because most forums since 2008 have been using the new version of phpbb :D
User avatar
Krom
DBB Database Master
DBB Database Master
Posts: 16137
Joined: Sun Nov 29, 1998 3:01 am
Location: Camping the energy center. BTW, did you know you can have up to 100 characters in this location box?
Contact:

Re: Testing open in new window/tab modification

Post by Krom »

An alternative if you are a Firefox user is to install greasemonkey and set this as a user script:

Code: Select all

// ==UserScript==
// @name           DescentBB.net set link target attribute
// @namespace      descentbb.net
// @description    Fix the target of hyperlinks so they open in a new tab/window
// @include        http://descentbb.net/viewtopic.php*
// @include        http://www.descentbb.net/viewtopic.php*
// ==/UserScript==
var a = document.getElementsByTagName('a');
for (i = 0; i < a.length; i++) a[i].setAttribute('target','_blank');
The added bonus is you can edit in more: // @include http://someotherphpbbsite.com" onclick="window.open(this.href);return false; to make other phpbb3 based forums behave the same way. Or you can edit the script and replace the '_blank' with '_self' to reverse the behavior on sites that use new tabs/windows when you don't want them to.

Also with a little tweaking of the browser Google Chrome users can use this script too.
User avatar
KoolBear
DBB Co-Founder
DBB Co-Founder
Posts: 10132
Joined: Thu Nov 05, 1998 12:01 pm
Location: Houston, TX USA
Contact:

Re: Testing open in new window/tab modification

Post by KoolBear »

Nice, any odea why XHTML dropped it? I guess it's a legacy feature and it has been replaced by something else?
User avatar
Aus-RED-5
DBB Friend
DBB Friend
Posts: 1604
Joined: Fri Apr 23, 2004 7:27 am
Location: Adelaide, South Australia
Contact:

Re: Testing open in new window/tab modification

Post by Aus-RED-5 »

KB, it's works.

Thank you! :)
Prepare for DESCENT!
User avatar
fliptw
DBB DemiGod
DBB DemiGod
Posts: 6459
Joined: Sat Oct 24, 1998 2:01 am
Location: Calgary Alberta Canada

Re: Testing open in new window/tab modification

Post by fliptw »

KoolBear wrote:Nice, any odea why XHTML dropped it? I guess it's a legacy feature and it has been replaced by something else?
Its valid in transitional XHTML/HTML4, but not the strict versions.

Its back in HTML5. Go figure. I wonder if they had second thoughts on that one.
User avatar
Aus-RED-5
DBB Friend
DBB Friend
Posts: 1604
Joined: Fri Apr 23, 2004 7:27 am
Location: Adelaide, South Australia
Contact:

Re: Testing open in new window/tab modification

Post by Aus-RED-5 »

hummm... The link to KB's website opened in a new tab, but why didn't this one do the same?

EDIT: Well I ended up using Krom's suggestion. It works too, but if click on New Post, New Reply, PM, Quote or even Edit (pretty much anything with a link). They will be opened in a new tab.... Doh! Not sure I like this! :lol:
Prepare for DESCENT!
User avatar
KoolBear
DBB Co-Founder
DBB Co-Founder
Posts: 10132
Joined: Thu Nov 05, 1998 12:01 pm
Location: Houston, TX USA
Contact:

Re: Testing open in new window/tab modification

Post by KoolBear »

did you just paste the url straight in or did u enter the bbcode?

This is the url only pasted below...
" onclick="window.open(this.href);return false;

EDITED 2/10/11 10am cst
Sorry my bad that was a stupid question obviously you used the bbcode, let me see what else I can do:P
User avatar
Krom
DBB Database Master
DBB Database Master
Posts: 16137
Joined: Sun Nov 29, 1998 3:01 am
Location: Camping the energy center. BTW, did you know you can have up to 100 characters in this location box?
Contact:

Re: Testing open in new window/tab modification

Post by Krom »

Yeah, that is the one downside of the script; its an all or nothing setting.
User avatar
fliptw
DBB DemiGod
DBB DemiGod
Posts: 6459
Joined: Sat Oct 24, 1998 2:01 am
Location: Calgary Alberta Canada

Re: Testing open in new window/tab modification

Post by fliptw »

try this:

Code: Select all

// ==UserScript==
// @name           DescentBB.net set link target attribute
// @namespace      descentbb.net
// @description    Fix the target of hyperlinks so they open in a new tab/window
// @include        http://descentbb.net/viewtopic.php*
// @include        http://www.descentbb.net/viewtopic.php*
// ==/UserScript==
var a = document.getElementsByTagName('a');

for (i = 0; i < a.length; i++) if(a[i].className=='postlink') a[i].setAttribute('target','_blank');
User avatar
Krom
DBB Database Master
DBB Database Master
Posts: 16137
Joined: Sun Nov 29, 1998 3:01 am
Location: Camping the energy center. BTW, did you know you can have up to 100 characters in this location box?
Contact:

Re: Testing open in new window/tab modification

Post by Krom »

fliptw wrote:try this:
That works perfectly, good idea on checking the class name.

One question then, is it possible to run that script automatically by editing it into the header without requiring an extra browser plugin?
User avatar
fliptw
DBB DemiGod
DBB DemiGod
Posts: 6459
Joined: Sat Oct 24, 1998 2:01 am
Location: Calgary Alberta Canada

Re: Testing open in new window/tab modification

Post by fliptw »

You can.
User avatar
KoolBear
DBB Co-Founder
DBB Co-Founder
Posts: 10132
Joined: Thu Nov 05, 1998 12:01 pm
Location: Houston, TX USA
Contact:

Re: Testing open in new window/tab modification

Post by KoolBear »

fliptw wrote:You can.
Will you share and I'll edited into the header.
User avatar
fliptw
DBB DemiGod
DBB DemiGod
Posts: 6459
Joined: Sat Oct 24, 1998 2:01 am
Location: Calgary Alberta Canada

Re: Testing open in new window/tab modification

Post by fliptw »

Go ahead. Just put that code between the script tags and its golden.
User avatar
KoolBear
DBB Co-Founder
DBB Co-Founder
Posts: 10132
Joined: Thu Nov 05, 1998 12:01 pm
Location: Houston, TX USA
Contact:

Re: Testing open in new window/tab modification

Post by KoolBear »

fliptw wrote:Go ahead. Just put that code between the script tags and its golden.
kool beans thanks
User avatar
Krom
DBB Database Master
DBB Database Master
Posts: 16137
Joined: Sun Nov 29, 1998 3:01 am
Location: Camping the energy center. BTW, did you know you can have up to 100 characters in this location box?
Contact:

Re: Testing open in new window/tab modification

Post by Krom »

If that script works KB, you should probably remove the board modification you were trying just to play it safe.

Oh, and if you do put it in, you only need the two bottom lines, all the stuff at the top that starts with the // is irrelevant for a script that is built into the page.
User avatar
KoolBear
DBB Co-Founder
DBB Co-Founder
Posts: 10132
Joined: Thu Nov 05, 1998 12:01 pm
Location: Houston, TX USA
Contact:

Re: Testing open in new window/tab modification

Post by KoolBear »

Krom wrote:If that script works KB, you should probably remove the board modification you were trying just to play it safe.

Oh, and if you do put it in, you only need the two bottom lines, all the stuff at the top that starts with the // is irrelevant for a script that is built into the page.
;) otay buckwheat :P
User avatar
Aus-RED-5
DBB Friend
DBB Friend
Posts: 1604
Joined: Fri Apr 23, 2004 7:27 am
Location: Adelaide, South Australia
Contact:

Re: Testing open in new window/tab modification

Post by Aus-RED-5 »

fliptw wrote:try this..........
Thanks fliptw, that worked! :)
Prepare for DESCENT!
Post Reply