Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Template Modifications
Open local links in same window; external links in new window Details »»
Open local links in same window; external links in new window
Version: 1.00, by djbaxter djbaxter is offline
Developer Last Online: Aug 2021 Show Printable Version Email this Page

Category: BB Code Enhancements - Version: 4.2.0 Rating:
Released: 07-27-2012 Last Update: Never Installs: 21
Template Edits
Re-useable Code  
No support by the author.

By default, vBulletin opens all links in posts in a new window (target="_blank").

This mod opens local links (i.e., links from your domain) in the same window (target="_self"), and external links in a new window or tab (target="_blank").

INSTRUCTIONS:

AdminCP >> Style Manager >> Common Templates >> headinclude

FIND in headinclude (this is where I added the code but probably anywhere would work):

PHP Code:
<vb:if condition="$stylevar['favicon']">
    <
link rel="Shortcut Icon" href="{vb:stylevar favicon}" type="image/x-icon" />
</
vb:if> 
ADD AFTER:

PHP Code:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<
script type="text/javascript">
$(
document).ready(function() {
    $(
"a[href^=http]").each(function(){
        if(
this.href.indexOf(location.hostname) == -1) {
           $(
this).attr('target','_blank');
        }else{
           $(
this).attr('target','_self');
        }
    })
});
</
script
Save. Done.

Thanks to my son, Wilder Tweedale, for assistance with the code.

Update:

Quote:
Originally Posted by BirdOPrey5 View Post
VB4 uses jquery on only a few pages. Yahoo YUI is the default library on all pages.
BOP5 has just published a javascript version of this as a product, which may be easier for many to implement and which avoids possible increases in page load times.

See http://www.qapla.com/mods/misc.php?d...extlinkingbop5

Download Now

File Type: txt Open internal links same window external links new window.txt (600 Bytes, 40 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
blind-eddie

Comments
  #2  
Old 07-28-2012, 12:22 PM
djbaxter djbaxter is offline
 
Join Date: Aug 2006
Location: Ottawa, Canada
Posts: 2,601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Before someone asks the obvious question...

Q: How is this mod different from the mod by SweCastel https://vborg.vbsupport.ru/showthread.php?t=256195?

A: SweCastel's mod requires editing one of the core vBulletin files. I dislike doing that because it means re-editing the file with every update. The current mod requires template edits only.
Reply With Quote
Благодарность от:
oldz442
  #3  
Old 07-28-2012, 08:23 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

This is a great idea, I use a custom BBCode for local links on my forum but it's annoying to have to worry about which are local and which aren't.

I would just give a heads up to people if they are already loading jquery on their pages they don't need to load it twice- actually 2 different jquery versions may conflict.
Reply With Quote
2 благодарности(ей) от:
djbaxter, puertoblack2003
  #4  
Old 07-28-2012, 10:58 PM
djbaxter djbaxter is offline
 
Join Date: Aug 2006
Location: Ottawa, Canada
Posts: 2,601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
This is a great idea, I use a custom BBCode for local links on my forum but it's annoying to have to worry about which are local and which aren't.
Thanks.

Quote:
Originally Posted by BirdOPrey5 View Post
I would just give a heads up to people if they are already loading jquery on their pages they don't need to load it twice- actually 2 different jquery versions may conflict.
To be honest, I thought it was loaded in native vBulletin installations but couldn't get the script to work without the load line added.
Reply With Quote
  #5  
Old 07-28-2012, 11:51 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

VB4 uses jquery on only a few pages. Yahoo YUI is the default library on all pages.
Reply With Quote
  #6  
Old 08-04-2012, 12:07 PM
djbaxter djbaxter is offline
 
Join Date: Aug 2006
Location: Ottawa, Canada
Posts: 2,601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
VB4 uses jquery on only a few pages. Yahoo YUI is the default library on all pages.
BOP5 has just published a javascript version of this as a product, which may be easier for many to implement and which avoids possible increases in page load times.

See http://www.qapla.com/mods/misc.php?d...extlinkingbop5
Reply With Quote
  #7  
Old 08-04-2012, 08:21 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I didn't want to release my own here since if it wasn't for yours I wouldn't have thought to do it.
Reply With Quote
  #8  
Old 08-04-2012, 08:48 PM
djbaxter djbaxter is offline
 
Join Date: Aug 2006
Location: Ottawa, Canada
Posts: 2,601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well, suffice it to say that I'm now using yours.

And I wouldn't be offended in the slightest if you re-released your mod here.
Reply With Quote
Благодарность от:
BirdOPrey5
  #9  
Old 08-05-2012, 01:29 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks. I put it up here: https://vborg.vbsupport.ru/showthread.php?t=286348 :up:
Reply With Quote
  #10  
Old 08-05-2012, 01:39 PM
djbaxter djbaxter is offline
 
Join Date: Aug 2006
Location: Ottawa, Canada
Posts: 2,601
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Excellent... To others, I'm now using the BOP5 mod on four vB4 forums... highly recommended.
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:32 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.09529 seconds
  • Memory Usage 2,328KB
  • Queries Executed 24 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (2)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (5)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (4)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (9)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete