Page 6 of 6

Re: [RC] Opening External Link in New Window

Posted: Sun Nov 10, 2013 9:55 pm
by TruckingAlong
Just a note: I've found this works great with "http://" or just "www." without "http://", but it doesn't work for "https://".

I assume that's missing in the ajax code, or something like that. I tried duplicating the second script tag group an changing the second group to ... $('a[href^="https://"]') ..., but that didn't work.

Oh well, that's not really very tragic, the rest works just fine, regardless of whether a forum member uses the url bbcode tags. Most don't. :|

Re: [RC] Opening External Link in New Window

Posted: Fri Jan 10, 2014 5:40 pm
by bodiniusz
Hello,

has anybody installed this through auto mod on 3.0.12?

Thanks

Re: [RC] Opening External Link in New Window

Posted: Sat Jan 18, 2014 4:09 pm
by bubban
bodiniusz wrote:Hello,

has anybody installed this through auto mod on 3.0.12?

Thanks
Yes, I just did it now and it looks like it's working. Thanks Digioz, great mod!

Re: [RC] Opening External Link in New Window

Posted: Mon Feb 10, 2014 11:32 pm
by MarkDHamill
Deleted text. Issue was elsewhere.

Re: [RC] Opening External Link in New Window

Posted: Sun Mar 23, 2014 11:07 am
by judgedredd
Its annoying when another forum using the older phpbb 2.x has links opening up in a new window and then I find that my forum using phpbb 3.0.12 doesn't have this ability.

Soooooooo coming here and finding this MOD I thought 'Great!'.

Installed it and it did not work. It was added by hand, not through AUTOMOD.

Here is where I put it (code is right at the bottom of the following code in the header section of the overall_header.html file):

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="{S_CONTENT_DIRECTION}" lang="{S_USER_LANG}" xml:lang="{S_USER_LANG}">
<head>

<meta http-equiv="content-type" content="text/html; charset={S_CONTENT_ENCODING}" />
<meta http-equiv="content-style-type" content="text/css" />
<meta http-equiv="content-language" content="{S_USER_LANG}" />
<meta http-equiv="imagetoolbar" content="no" />
<meta name="resource-type" content="document" />
<meta name="distribution" content="global" />
<meta name="keywords" content="" />
<meta name="description" content="" />
{META}
<title>{SITENAME} &bull; <!-- IF S_IN_MCP -->{L_MCP} &bull; <!-- ELSEIF S_IN_UCP -->{L_UCP} &bull; <!-- ENDIF -->{PAGE_TITLE}</title>

<!-- IF S_ENABLE_FEEDS -->
	<!-- IF S_ENABLE_FEEDS_OVERALL --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {SITENAME}" href="{U_FEED}" /><!-- ENDIF -->
	<!-- IF S_ENABLE_FEEDS_NEWS --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_FEED_NEWS}" href="{U_FEED}?mode=news" /><!-- ENDIF -->
	<!-- IF S_ENABLE_FEEDS_FORUMS --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_ALL_FORUMS}" href="{U_FEED}?mode=forums" /><!-- ENDIF -->
	<!-- IF S_ENABLE_FEEDS_TOPICS --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_FEED_TOPICS_NEW}" href="{U_FEED}?mode=topics" /><!-- ENDIF -->
	<!-- IF S_ENABLE_FEEDS_TOPICS_ACTIVE --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_FEED_TOPICS_ACTIVE}" href="{U_FEED}?mode=topics_active" /><!-- ENDIF -->
	<!-- IF S_ENABLE_FEEDS_FORUM and S_FORUM_ID --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_FORUM} - {FORUM_NAME}" href="{U_FEED}?f={S_FORUM_ID}" /><!-- ENDIF -->
	<!-- IF S_ENABLE_FEEDS_TOPIC and S_TOPIC_ID --><link rel="alternate" type="application/atom+xml" title="{L_FEED} - {L_TOPIC} - {TOPIC_TITLE}" href="{U_FEED}?f={S_FORUM_ID}&t={S_TOPIC_ID}" /><!-- ENDIF -->
<!-- ENDIF -->

<!--
	phpBB style name: prosilver
	Based on style:   prosilver (this is the default phpBB3 style)
	Original author:  Tom Beddard ( http://www.subBlue.com/ )
	Modified by:
-->

<script type="text/javascript">
// <![CDATA[
	var jump_page = '{LA_JUMP_PAGE}:';
	var on_page = '{ON_PAGE}';
	var per_page = '{PER_PAGE}';
	var base_url = '{A_BASE_URL}';
	var style_cookie = 'phpBBstyle';
	var style_cookie_settings = '{A_COOKIE_SETTINGS}';
	var onload_functions = new Array();
	var onunload_functions = new Array();

	<!-- IF S_USER_PM_POPUP and S_NEW_PM -->
		var url = '{UA_POPUP_PM}';
		window.open(url.replace(/&/g, '&'), '_phpbbprivmsg', 'height=225,resizable=yes,scrollbars=yes, width=400');
	<!-- ENDIF -->

	/**
	* Find a member
	*/
	function find_username(url)
	{
		popup(url, 760, 570, '_usersearch');
		return false;
	}

	/**
	* New function for handling multiple calls to window.onload and window.unload by pentapenguin
	*/
	window.onload = function()
	{
		for (var i = 0; i < onload_functions.length; i++)
		{
			eval(onload_functions[i]);
		}
	};

	window.onunload = function()
	{
		for (var i = 0; i < onunload_functions.length; i++)
		{
			eval(onunload_functions[i]);
		}
	};

// ]]>
</script>
<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/styleswitcher.js"></script>
<script type="text/javascript" src="{T_SUPER_TEMPLATE_PATH}/forum_fn.js"></script>

<link href="{T_THEME_PATH}/print.css" rel="stylesheet" type="text/css" media="print" title="printonly" />
<link href="{T_STYLESHEET_LINK}" rel="stylesheet" type="text/css" media="screen, projection" />

<link href="{T_THEME_PATH}/normal.css" rel="stylesheet" type="text/css" title="A" />
<link href="{T_THEME_PATH}/medium.css" rel="alternate stylesheet" type="text/css" title="A+" />
<link href="{T_THEME_PATH}/large.css" rel="alternate stylesheet" type="text/css" title="A++" />

<!-- IF S_CONTENT_DIRECTION eq 'rtl' -->
	<link href="{T_THEME_PATH}/bidi.css" rel="stylesheet" type="text/css" media="screen, projection" />
<!-- ENDIF -->

<!-- Added following script MOD code on 23 March 2014 -->
<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>

</head>
Any idea why it doesn't work? Flushed cache twice, deleted file from server and re-uploaded the altered one. Still nothing.

Re: [RC] Opening External Link in New Window

Posted: Sun Mar 23, 2014 11:36 am
by judgedredd
Well..... I read another post about refreshing the template files, went and did it and the MOD worked. Wow!
Thank you for this MOD. Its awesome!

Here are the instructions I found:

Don't forget to refresh the appropriate style component after you have made all the changes by going to your Administration Control Panel => Styles => (Templates/Themes) => prosilver and click on refresh.

Re: [RC] Opening External Link in New Window

Posted: Sun Dec 28, 2014 10:55 pm
by kaszkai
TruckingAlong wrote:Just a note: I've found this works great with "http://" or just "www." without "http://", but it doesn't work for "https://".

I assume that's missing in the ajax code, or something like that. I tried duplicating the second script tag group an changing the second group to ... $('a[href^="https://"]') ..., but that didn't work.

Oh well, that's not really very tragic, the rest works just fine, regardless of whether a forum member uses the url bbcode tags. Most don't. :|
find:

Code: Select all

$(document).ready(function() {
      $('a[href^="http://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   }); 
add after:

Code: Select all

$(document).ready(function() {
      $('a[href^="https://"]').filter(function() {return this.hostname && this.hostname !== location.hostname;}).attr('target', '_blank');
   }); 

Re: [RC] Opening External Link in New Window

Posted: Fri Oct 23, 2015 2:05 pm
by clight77
Nice :)
Thanks

Re: [RC] Opening External Link in New Window

Posted: Fri Oct 23, 2015 2:33 pm
by RMcGirr83

Code: Select all

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

Re: [RC] Opening External Link in New Window

Posted: Fri Oct 23, 2015 4:10 pm
by clight77
After using for a bit I found that my collapse categories no longer work phpbb 3.0.12 SE_Gamer_Dark

Thanks

Re: [RC] Opening External Link in New Window

Posted: Fri Oct 23, 2015 4:50 pm
by RMcGirr83
Probably because of this line

Code: Select all

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>  
you probably have two jQuery libraries being loaded.

Re: [RC] Opening External Link in New Window

Posted: Fri Oct 23, 2015 5:44 pm
by clight77
RMcGirr83 wrote:Probably because of this line

Code: Select all

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>  
you probably have two jQuery libraries being loaded.
Thanks :)

I have this:

Code: Select all

<script type="text/javascript" src="{T_TEMPLATE_PATH}/jquery-1.9.1.min.js"></script>
And this:

Code: Select all

<script type="text/javascript" src="{ROOT_PATH}mchat/jquery-1.10.2.min.js"></script>
Do I need them both ?

Cheers

EDIT: solved..
Just replaced my code

Code: Select all

<script type="text/javascript" src="{T_TEMPLATE_PATH}/jquery-1.9.1.min.js"></script>
with this:

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>

Re: [RC] Opening External Link in New Window

Posted: Tue Oct 27, 2015 9:44 pm
by Derky
This topic has been marked as [ABD] - Abandoned as the MOD author has not replied here recently. If the author wishes to continue development, please PM anyone on the Extensions Team to request this topic be unlocked.

Thank you,
The phpBB Extensions Team