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

Home » FUDforum » How To » How to disable target=_blank
Show: Today's Messages :: Unread Messages :: Polls :: Message Navigator
| Subscribe to topic | Bookmark topic 
Switch to threaded view of this topic Create a new topic Submit Reply
How to disable target=_blank [message #162940] Sat, 04 September 2010 13:01 Go to next message
milki is currently offline  milki
Messages: 1
Registered: September 2010
Karma: 0
Junior Member
add to buddy list
ignore all messages by this user
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 16:06 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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?
Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to previous messageGo to next message
Re: How to disable target=_blank [message #162976 is a reply to message #162943] Mon, 13 September 2010 11:30 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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?
Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to previous messageGo to next message
Re: How to disable target=_blank [message #163027 is a reply to message #162977] Sun, 19 September 2010 11:09 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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"
  });

Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to previous messageGo to next message
Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to previous messageGo to next message
Re: How to disable target=_blank [message #163030 is a reply to message #163028] Sun, 19 September 2010 11:23 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
No, it will only open external links in a new window (basically only those posted by users).
Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to previous messageGo to next message
Message by Ernesto is ignored  [reveal message]  [reveal all messages by Ernesto]  [stop ignoring this user] Go to previous messageGo to next message
Re: How to disable target=_blank [message #163033 is a reply to message #163032] Sun, 19 September 2010 12:02 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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 12:15 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user

Should we remove target=_blank from external links?[ 5 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 13:11 Go to previous messageGo to next message
tw_nick   United States
Messages: 57
Registered: October 2010
Location: Dallas, TX
Karma: 0
Member
add to buddy list
ignore all messages by this user

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 05:12 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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 13:00 Go to previous messageGo to next message
tw_nick   United States
Messages: 57
Registered: October 2010
Location: Dallas, TX
Karma: 0
Member
add to buddy list
ignore all messages by this user

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] Tue, 28 December 2010 21:27 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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 06:44 Go to previous messageGo to next message
The Witcher is currently offline  The Witcher   United States
Messages: 662
Registered: May 2009
Location: USA
Karma: 2
Senior Member
add to buddy list
ignore all messages by this user
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 07:38 Go to previous messageGo to next message
tw_nick   United States
Messages: 57
Registered: October 2010
Location: Dallas, TX
Karma: 0
Member
add to buddy list
ignore all messages by this user

Perfect! Thanks!!
Re: How to disable target=_blank [message #164180 is a reply to message #164166] Fri, 07 January 2011 13:00 Go to previous messageGo to next message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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 13:02 Go to previous messageGo to next message
tw_nick   United States
Messages: 57
Registered: October 2010
Location: Dallas, TX
Karma: 0
Member
add to buddy list
ignore all messages by this user

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 06:30 Go to previous messageGo to next message
The Witcher is currently offline  The Witcher   United States
Messages: 662
Registered: May 2009
Location: USA
Karma: 2
Senior Member
add to buddy list
ignore all messages by this user
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 08:49 Go to previous messageGo to next message
Moachist is currently offline  Moachist   United States
Messages: 35
Registered: April 2011
Karma: 0
Member
add to buddy list
ignore all messages by this user
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 00:51 Go to previous message
naudefj is currently offline  naudefj   South Africa
Messages: 3732
Registered: December 2004
Karma: 26
Senior Member
Administrator
Core Developer
remove from buddy list
ignore all messages by this user
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.
Quick Reply
Formatting Tools:   
  Switch to threaded view of this topic Create a new topic
Previous Topic: Changes won't take affect.
Next Topic: Moderated forum?
Goto Forum:
  

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

Current Time: Fri Jul 10 04:56:31 EDT 2020

Total time taken to generate the page: 0.02063 seconds