FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » How To » How to disable target=_blank
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
How to disable target=_blank [message #162940] Sat, 04 September 2010 17:01 Go to next message
milki is currently offline  milki
Messages: 1
Registered: September 2010
Karma: 0
Junior Member
I have modifed my templates already to use HTML5 instead of XHTML, so it's not a technical problem. However I frown upon the usability aspect of that.

So how or where can I disable those oldschool target=_blank attributes? Is there an option for that, or if it's in the templates, which one? Or if FF is hardcoded to augment {url}s with targets, in which script?

Thanks!
mario
Re: How to disable target=_blank [message #162942 is a reply to message #162940] Sat, 04 September 2010 20:06 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
You can run a "grep" against the template files:

buddy_list.tmpl
drawmsg.tmpl
drawpmsg.tmpl
finduser.tmpl
ignore_list.tmpl
referals.tmpl
reported.tmpl
usrinfo.tmpl

Any particular reason why it shouldn't be used any more?
Re: How to disable target=_blank [message #162943 is a reply to message #162942] Sat, 04 September 2010 21:47 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
post_proc.inc.t is the file you want if you wanna remove/change the automatic add of target="_blank" to BBCODE URL links

Re: How to disable target=_blank [message #162976 is a reply to message #162943] Mon, 13 September 2010 15:30 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Well, maybe we should remove all the link targets from upcoming 3.0.2 release.
Are there any reasons why we shouldn't?
What do you guys think?
Re: How to disable target=_blank [message #162977 is a reply to message #162976] Mon, 13 September 2010 16:40 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
No, it should be kept in. You don't want to force users away from your page when they click links. It should most definitely open a new window/tab, you want users on your page as much as possible, not as little as possible. Out of all ideas you have had Sir, that was the terriblestestest! =)

Re: How to disable target=_blank [message #163027 is a reply to message #162977] Sun, 19 September 2010 15:09 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
They should be removed as it's generally seen as a bad practice.

If you need this functionality, you can paste this JS code into your html:
$('a[href^="http://"]')
  .attr({
    target: "_blank", 
    title: "Opens in a new window"
  });

Re: How to disable target=_blank [message #163028 is a reply to message #162940] Sun, 19 September 2010 15:16 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
That would open all links into a new window, not just the links that are in a post.

I don't think that I have ever seen any forum software that doesn't open up links in posts in a new window/tab.

I don't see how target="_blank" would be bad practice, it's VERY widely used and it works great to keep a user on your site.

What is bad practice are javascript links to open up new windows, because those you cannot control on a user basis - IE, I often click links with my middle mouse to open them in a new tab (to be certain they open in a new tab, since i dont wanna navigate away from the current page) - but if its a javascript link, the opened page will not work, since the browsers cannot interpret it.


Mjeh, we often agree on much, but this one I have to say that me, and actually every single other forum software agrees, against you :po


Re: How to disable target=_blank [message #163029 is a reply to message #163028] Sun, 19 September 2010 15:17 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
If you could point me to somewhere that would in any way, shape or form indicate that it is bad practice, feel free to, would be very interesting to seeĀ“=)

Re: How to disable target=_blank [message #163030 is a reply to message #163028] Sun, 19 September 2010 15:23 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
No, it will only open external links in a new window (basically only those posted by users).
Re: How to disable target=_blank [message #163031 is a reply to message #163030] Sun, 19 September 2010 15:34 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
XHTML Strict is not, according to me, "most desired practice" etc etc.

People who are WC3 crazy would rip out target=_blank and replace it with onclick="window.open(this.href,'_blank');return false;" which actually IS bad practice, since it breaks the middle mouse button functionality in _ALL_ browsers.


Let's say my mom is visiting a forum that does not have target="_blank".
She is reading the recepie thread.
One post called "Bread" links her to the site "Bread'R'Us"
My mom clicks the link.
She enters the site Bread'R'Us, it loads a bit slow since its a bloated site. She navigates on that site with 3-4 clicks to get to a recepie she wants.

Now she wants to get back to that lovely forum and that magnificent thread that had tips of all the recepie sites!

So she hits her back button. Oh shit, since the site used a script to redirect her search for the recepie, a popup is prompted if she wants to submit the data again!

If course she doesnt want to do that, she clicks cancel and remains on her current page.

My mom tries to hit the back button again. Same prompt appears. My mom is now confused, but she clicks ok.

Boom, the search enables again, and she is STILL on the same page.

She is now desperate, so she is clicking the back button like a crazy person, and before the scripts on the page loads (the page is very slow, remember?) she manages to get back 2 pages, to the recepie list again on bread's'r'us but she doesnt know this, since its such a slow site.

She clicks the back button again, waits, page loads, still not the lovely forum thread.





OR

She clicks the link on the forum, a new tab appears and flashes. She clicks the tab, finds her recepies, then clicks the forum tab and she can view the little forum again!


For usability and user experience, I'd go with option number 2!


Re: How to disable target=_blank [message #163032 is a reply to message #163027] Sun, 19 September 2010 15:36 Go to previous messageGo to next message
Ernesto is currently offline  Ernesto   Sweden
Messages: 413
Registered: August 2005
Karma: 0
Senior Member
naudefj wrote on Sun, 19 September 2010 17:09
They should be removed as it's generally seen as a bad practice.

If you need this functionality, you can paste this JS code into your html:
$('a[href^="http://"]')
  .attr({
    target: "_blank", 
    title: "Opens in a new window"
  });


This requires the user to have javascript enabled AND use the jquery library

(Although I always advocate that javascript is required in a modern web experience, there are still some people who have it disabled)


[Updated on: Sun, 19 September 2010 15:36]

Report message to a moderator

Re: How to disable target=_blank [message #163033 is a reply to message #163032] Sun, 19 September 2010 16:02 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
I do agree that the "onclick window.open" method sucks, so we won't use that.

If we don't use target="_blank" users can simply right click and select "open in new window". If they don't, the BACK button will still work as expected. No funny stuff.

FUDforum uses jQuery anyway. So, if you don't like it, you can simply drop in the provided code to change the link behaviour.
Re: How to disable target=_blank [message #163034 is a reply to message #162940] Sun, 19 September 2010 16:15 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer

Should we remove target=_blank from external links?[ 6 votes ]
1.
2.
3.
 

What do you think?
Re: How to disable target=_blank [message #163947 is a reply to message #163034] Tue, 14 December 2010 18:11 Go to previous messageGo to next message
tw_nick   United States
Messages: 57
Registered: October 2010
Location: Dallas, TX
Karma: 0
Member

What file would need to be edited to invoke the target="_blank" function? My users are consistently asking for links to open in a new tab automatically.
Re: How to disable target=_blank [message #163957 is a reply to message #163947] Thu, 16 December 2010 10:12 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Paste the above mentioned jQuery snippet (message #163027) into your /js/lib.js file.
Re: How to disable target=_blank [message #164014 is a reply to message #163957] Tue, 28 December 2010 18:00 Go to previous messageGo to next message
tw_nick   United States
Messages: 57
Registered: October 2010
Location: Dallas, TX
Karma: 0
Member

I did as you suggested, but links still open in the same window as opposed to a new window or tab. Should I be placing the snipped under a particular function in the lib.js file? Or just stuck on the very end of the file? And do I need to rebuild my templates or anything like that?

Sorry to ask such elementary questions, but I'm a coding ignoramus. Sad
Re: How to disable target=_blank [message #164019 is a reply to message #164014] Wed, 29 December 2010 02:27 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
Add it right after $(function init() {.
No rebuilding required.
Re: How to disable target=_blank [message #164166 is a reply to message #164019] Fri, 07 January 2011 11:44 Go to previous messageGo to next message
The Witcher is currently offline  The Witcher   United States
Messages: 675
Registered: May 2009
Location: USA
Karma: 3
Senior Member
When this topic 1st came out I did not quite understand it, but I believe I do now. Seems that whenever I follow a link from the forum it's a pain to get back to it because the computer wants to resend the data, I much preferred the old open new window/tab functionality.

To recap, in order to fix this insert:

$('a[href^="http://"]')
  .attr({
    target: "_blank", 
    title: "Opens in a new window"
  });


Into the /js/lib.js file, right after :

$(function init() {


Which is located right around line 437 which means add the code on line 438.

I believe if possible this should be a selectable option for future releases if not default!




"I'm a Witcher, I solve human problems; not always using a sword!"
Re: How to disable target=_blank [message #164171 is a reply to message #164166] Fri, 07 January 2011 12:38 Go to previous messageGo to next message
tw_nick   United States
Messages: 57
Registered: October 2010
Location: Dallas, TX
Karma: 0
Member

Perfect! Thanks!!
Re: How to disable target=_blank [message #164180 is a reply to message #164166] Fri, 07 January 2011 18:00 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
The Witcher wrote:
I believe if possible this should be a selectable option for future releases if not default!


Someone should turn it into a plugin!
Just don't look at me. Life is short and I cannot spend all of it coding weird stuff.
Re: How to disable target=_blank [message #164181 is a reply to message #164180] Fri, 07 January 2011 18:02 Go to previous messageGo to next message
tw_nick   United States
Messages: 57
Registered: October 2010
Location: Dallas, TX
Karma: 0
Member

Personally, I think it's more suited to a user preference or a global setting for the forum than for a plug-in, but I can't write code, so I take what I can get. (Like copy/paste as above. Smile )
Re: How to disable target=_blank [message #164190 is a reply to message #164181] Sat, 08 January 2011 11:30 Go to previous messageGo to next message
The Witcher is currently offline  The Witcher   United States
Messages: 675
Registered: May 2009
Location: USA
Karma: 3
Senior Member
I agree and like you I can't write code but I think I understand naudfj's point, a plug in would be easier than coding it into the software and would make it a selectable item for each admin too pick and chose, coding it takes time and effort which someone must expend (even though they don't agree with the goal), it makes the software ever more complicated and ever larger.....

Naudfj being a coder looks at it a different way than you and I do which is why so much of what he and ernesto shares is way over my head they are talking code, and I am hearing it as a user so I struggle to make sense of it. But each time I do understand a part of it I am that much more able to help myself and others.

That we have the above option is only because various users (of different knowledge levels) have taken the time to try and understand it and discuss it. And the more of that that goes on the more we will understand things.


"I'm a Witcher, I solve human problems; not always using a sword!"
Re: How to disable target=_blank [message #165131 is a reply to message #164190] Sat, 30 April 2011 12:49 Go to previous messageGo to next message
Moachist is currently offline  Moachist   United States
Messages: 35
Registered: April 2011
Karma: 0
Member
Hi - Trying to figure this one out. I added this code and:
Chrome and IE8 work perfectly. Opens new tab.
Firefox does nothing. I am guessing this is a firefox setting failure instead of a code problem?
Re: How to disable target=_blank [message #165132 is a reply to message #165131] Sun, 01 May 2011 04:51 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3771
Registered: December 2004
Karma: 28
Senior Member
Administrator
Core Developer
It works for me with Firefox 3.6.16.

PS: Firefox have settings to control window and pop-up behaviour. You may need to review them.
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Changes won't take affect.
Next Topic: Moderated forum?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 04:20:32 GMT 2024

Total time taken to generate the page: 0.02690 seconds