[ABD] Opening External Link in New Window

Any abandoned MODs will be moved to this forum.

WARNING: MODs in this forum are not currently being supported or maintained by the original MOD author. Proceed at your own risk.
Forum rules
IMPORTANT: MOD Development Forum rules

WARNING: MODs in this forum are not currently being supported nor updated by the original MOD author. Proceed at your own risk.
User avatar
digioz
Registered User
Posts: 299
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia

[ABD] Opening External Link in New Window

Post by digioz »

Modification Name: Opening External Link in New Window
Author: digioz

Modification Description: Open External URL in a New Window
Modification Version: 1.0.0

Requirements: None
Supported PHPBB Versions: 3.0.8, 3.0.9, 3.0.10

Download: link_mod_1.0.0.zip
Source Code: DigiOz Github phpbb-mods

Demo: Demo Forum

Description: I was looking for this feature and the existing mods related to this subject all involved making changes to the actual database records, and I didn't want to do that. So this is an alternate way to open all external links using jQuery library

Image
Image

Update:
7/28/11 - Added ModX Installer Download Link for installing through AutoMod.
  • Open the file "./styles/prosilver/template/overall_header.html (repeat for all other styles).
  • Add the following code to the header region of the template (~line 92)

    Code: Select all

    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>          
    <script type="text/javascript">                                         
       $(document).ready(function() {
          $('a[href^="http://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
       });                     
    </script>
    
That's all!
Pete
Last edited by digioz on Tue Apr 03, 2012 12:51 am, edited 8 times in total.
DigiOz Multimedia
http://www.digioz.com
satguy
Registered User
Posts: 12
Joined: Mon Jun 07, 2010 10:12 pm

Re: [BETA] Opening External Link in New Window

Post by satguy »

Brilliant … I added it after this ..

Code: Select all

<!-- IF not S_USER_LOGGED_IN and not S_IN_UCP -->
	<form action="{U_LOGIN_LOGOUT}" method="post">
		<table class="toplogin" cellspacing="0">
		    <tr>
		        <td><span class="gensmall">{L_USERNAME}:</span></td>
		        <td><input class="post" type="text" name="username" size="10" style="width: 75px" /></td>
		        <td nowrap="nowrap"><input type="checkbox" checked="true" class="radio" name="autologin" /><span style="vertical-align: middle;" class="gensmall">{L_LOG_ME_IN}</span></td>
		    </tr>
		    <tr>
		        <td><span class="gensmall">{L_PASSWORD}:</span></td>
		        <td><input class="post" type="password" name="password" size="10" style="width: 75px" /></td>
		        <td><input type="submit" class="btnmain" name="login" value="{L_LOGIN}" /></td>
		    </tr>
		</table>
		{S_FORM_TOKEN}
	</form>
	<!-- ENDIF -->
I don't know why I put it there,, But it works just fine..

Thank You...
User avatar
digioz
Registered User
Posts: 299
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia

Re: [BETA] Opening External Link in New Window

Post by digioz »

You could do that. I included it in the header region because that's the recommended place for it. Doesn't mean it won't work elsewhere though. ;)
DigiOz Multimedia
http://www.digioz.com
artikkk
Registered User
Posts: 379
Joined: Sun Jan 04, 2009 1:37 pm
Location: Roma

Re: [BETA] Opening External Link in New Window

Post by artikkk »

not work for me.. please tell me where i place your code :oops:
sorry for my bad english :S
User avatar
digioz
Registered User
Posts: 299
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia

Re: [BETA] Opening External Link in New Window

Post by digioz »

The code goes in the overall header file, right before the </head> tag. Make sure to clear cache once you have made the change for it to take effect.
DigiOz Multimedia
http://www.digioz.com
tekknodevil
Registered User
Posts: 69
Joined: Mon Feb 08, 2010 6:53 pm
Location: Dresden, Germany

Re: [BETA] Opening External Link in New Window

Post by tekknodevil »

Thank you. Everything works fine.
sleevedbiker
Registered User
Posts: 789
Joined: Mon Oct 12, 2009 4:33 pm

Re: [BETA] Opening External Link in New Window

Post by sleevedbiker »

so this will automatically open external links in a new window? instead of the target="">
You ride with an outlaw, You die with an outlaw
tekknodevil
Registered User
Posts: 69
Joined: Mon Feb 08, 2010 6:53 pm
Location: Dresden, Germany

Re: [BETA] Opening External Link in New Window

Post by tekknodevil »

sleevedbiker wrote:so this will automatically open external links in a new window? instead of the target="">
yes. thats it.
User avatar
digioz
Registered User
Posts: 299
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia

Re: [BETA] Opening External Link in New Window

Post by digioz »

sleevedbiker wrote:so this will automatically open external links in a new window? instead of the target="">
Correct. This gives you an easy and clean way to open up all external hyperlinks in new windows.
DigiOz Multimedia
http://www.digioz.com
User avatar
keith10456
Registered User
Posts: 2315
Joined: Thu Feb 24, 2005 6:55 pm

Re: [BETA] Opening External Link in New Window

Post by keith10456 »

Thanks for sharing... ;)
tofm2
Registered User
Posts: 27
Joined: Wed Apr 25, 2007 1:19 pm

Re: [BETA] Opening External Link in New Window

Post by tofm2 »

wurks fine on supernova style (of course, method is script dependant, not style dependant/)
and easy.
Thanks
Ascareus
Registered User
Posts: 114
Joined: Thu Aug 19, 2010 8:45 pm

Re: [BETA] Opening External Link in New Window

Post by Ascareus »

i used slimbox
for viewing image linking
does this mod will make the image opened in new tab..??
by the way
based on modification rules
beta stage should provide download link ;)
User avatar
digioz
Registered User
Posts: 299
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia

Re: [BETA] Opening External Link in New Window

Post by digioz »

Ascareus wrote:i used slimbox
for viewing image linking
does this mod will make the image opened in new tab..??
by the way
based on modification rules
beta stage should provide download link ;)
I am not familiar with slimbox. Do you have a link for it?

As for the beta stage download link, I wasn't aware this was required. I will put a modx package together for this as soon as I find the time.
DigiOz Multimedia
http://www.digioz.com
User avatar
Terr0r
Registered User
Posts: 553
Joined: Thu May 05, 2011 3:39 pm
Location: The Netherlands

Re: [BETA] Opening External Link in New Window

Post by Terr0r »

Thanks this is working fine Yes Yes

EDIT

this script is working fine

but if you install the MChat and set the settings you can see the MChat on the index page and you will click on smilies or BBCodes it is than not working whit this script

how can i change that , that is working fine
if you can't fix it with ducktape you ain't using enough
if you want to search a MOD maybe you can find it here
For my MODS and BBCodes or other things that I have made take a look here
User avatar
JoelWong
Registered User
Posts: 64
Joined: Sat Oct 02, 2010 9:42 am
Name: joel wong

Re: [BETA] Opening External Link in New Window

Post by JoelWong »

Holy cow! I have been searching for this for AGES! Thanks!!!

Return to “[3.0.x] Abandoned MODs”