[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.
Robi052
Registered User
Posts: 22
Joined: Sun Dec 18, 2011 6:08 pm

Re: [RC] Opening External Link in New Window

Post by Robi052 »

https open in same window. How fix that? (twitter, facebook, etc.)
User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [RC] Opening External Link in New Window

Post by 4_seven »

try

find

Code: Select all

      $('a[href^="http://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });    
replace with (should work)

Code: Select all

      $('a[href^="(http||https)://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });    
or replace with (will work)

Code: Select all

      $('a[href^="http://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });    
      $('a[href^="https://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });    
after each test of both solutions clear all available board-, template-, style- and browser-caches to check it out
Current Mods | Mod Base | php(BB) programming | No help via PM
Robi052
Registered User
Posts: 22
Joined: Sun Dec 18, 2011 6:08 pm

Re: [RC] Opening External Link in New Window

Post by Robi052 »

Try booth, but dont work. Open in same window. In second when remove second (https) link working, but when is here open in same window. I purge template cache and board cache and browser.
This is my line

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"> 
   // <![CDATA[                                        
       $(document).ready(function() {
          $('a[href^="http://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });
          $('a[href^="https://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });         
      // ]]>                    
    </script>

User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [RC] Opening External Link in New Window

Post by 4_seven »

than wait for the author..
Current Mods | Mod Base | php(BB) programming | No help via PM
User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [RC] Opening External Link in New Window

Post by digioz »

The suggestion 4_seven made should have worked for you. Do you have any other Mods installed that may be interfering with this? If possible please provide a complete list of Mods you have installed.

Pete
DigiOz Multimedia
http://www.digioz.com
Robi052
Registered User
Posts: 22
Joined: Sun Dec 18, 2011 6:08 pm

Re: [RC] Opening External Link in New Window

Post by Robi052 »

digioz wrote:The suggestion 4_seven made should have worked for you. Do you have any other Mods installed that may be interfering with this? If possible please provide a complete list of Mods you have installed.

Pete
Manuall installed mods:
http://www.phpbb.com/customise/db/mod/d ... _no_avatar_/
http://www.phpbb.com/customise/db/mod/user_mention_mod/

I dont use automod.

Extra codes: Google analytics, etarget, xclaim contextual advertising,

Example: http://www.hedonist385.in/forum/viewtopic.php?f=5&t=105
1st link is http, second and third is https
User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [RC] Opening External Link in New Window

Post by digioz »

Neither of those two Mods use jQuery, so they shouldn't impact this Mod. Do your regular "http" open in new window ok?

Pete
DigiOz Multimedia
http://www.digioz.com
Robi052
Registered User
Posts: 22
Joined: Sun Dec 18, 2011 6:08 pm

Re: [RC] Opening External Link in New Window

Post by Robi052 »

digioz wrote:Neither of those two Mods use jQuery, so they shouldn't impact this Mod. Do your regular "http" open in new window ok?

Pete
Yes. When is only http, working fine. Try change code and add only one. Working fine and http and https when is only one.

When remove this code working fine

Code: Select all

$('a[href^="https://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });
User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [RC] Opening External Link in New Window

Post by digioz »

Here is the output I see on your site right now:

Code: Select all

    <script type="text/javascript"> 
   // <![CDATA[                                        
       $(document).ready(function() {
          $('a[href^="http://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });
          $('a[href^="https://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });         
      // ]]>                    
    </script>
But here is what it should be:

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');
	  $('a[href^="https://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });                     
</script>
Fixing that should fix this issue, but it looks like you have several other errors on there as well:

Image

I recommend looking into those as well, specially the ones related to your other script:

Code: Select all

<script src="http://engine.xclaimwords.net/script.aspx?partnerid=117498" type="text/javascript"></script>
DigiOz Multimedia
http://www.digioz.com
Robi052
Registered User
Posts: 22
Joined: Sun Dec 18, 2011 6:08 pm

Re: [RC] Opening External Link in New Window

Post by Robi052 »

Now working. Thanks. Forum is not valid but working. Thanks.
User avatar
4_seven
I've Been Banned!
Posts: 5155
Joined: Wed Apr 30, 2008 1:41 am

Re: [RC] Opening External Link in New Window

Post by 4_seven »

4_seven wrote:

Code: Select all

      $('a[href^="(http||https)://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   });    
this version not work? bcs. it would be more slim..
Current Mods | Mod Base | php(BB) programming | No help via PM
User avatar
durangod
Registered User
Posts: 789
Joined: Tue Nov 03, 2009 1:26 pm
Location: USA East Texas
Name: Dave

Re: [RC] Opening External Link in New Window

Post by durangod »

If you dont know it this mod is based off of modifying a prosilver based template. I wanted to use it on a Subsilver based template so i did it a bit different but same concept and it seems to be working just fine.

in your (subsilver based) overall_header.php just

find this.

Code: Select all

<!--[if lt IE 8]><link href="{T_THEME_PATH}/ie.css" rel="stylesheet" type="text/css" /><![endif]-->
add after

Code: Select all

<!-- added as a mod so that url opens in new window -->
<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>
<!-- end of mod -->
Seems to work, nice job on the mod there Digioz
Username is short for durango d (durangodave)
User avatar
digioz
Registered User
Posts: 297
Joined: Thu Feb 05, 2004 9:20 pm
Location: Chicago, IL
Name: DigiOz Multimedia
Contact:

Re: [RC] Opening External Link in New Window

Post by digioz »

Thanks for the contribution durangod.
DigiOz Multimedia
http://www.digioz.com
Ivo_BG
Registered User
Posts: 14
Joined: Tue Jan 24, 2012 11:19 pm

Re: [RC] Opening External Link in New Window

Post by Ivo_BG »

Durangod, do you mean overall_header.html ?

I only have an overall_header.html in /styles/subsilver2/template directory.
And I cannot find the line "<!--[if lt IE 8]><link href="{T_THEME_PATH ... "
tay666
Registered User
Posts: 15
Joined: Sat Dec 03, 2011 3:55 am

Re: [RC] Opening External Link in New Window

Post by tay666 »

Ivo_BG wrote:Durangod, do you mean overall_header.html ?

I only have an overall_header.html in /styles/subsilver2/template directory.
And I cannot find the line "<!--[if lt IE 8]><link href="{T_THEME_PATH ... "
Sane question here.
We are running subsilver2 and would love to get this mod working on our forum.
But I can't find that line either.
Locked

Return to “[3.0.x] Abandoned MODs”