How do i get links to open in new window.

Get help with installation and running phpBB 3.0.x here. Please do not post bug reports, feature requests, or MOD-related questions here.
Suggested Hosts
Forum rules
END OF SUPPORT: 1 January 2017 (announcement)
User avatar
RMcGirr83
Former Team Member
Posts: 21492
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: How do i get links to open in new window.

Post by RMcGirr83 »

If you are using the jQuery library this code placed in your overall_header.html file after the jQuery library stuffs will open all external links in a new window

Code: Select all

<script type="text/javascript">
$(function(){

	var source = removeSubdomain(location.hostname);
	$('a[href^="http://"], a[href^="https://"]').filter(function() {return this.hostname && removeSubdomain(this.hostname) !== source;}).attr('target', '_blank');
});
</script>
and if you don't have the jQuery library loaded in your overall_header.html file place this before the above

Code: Select all

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
then refresh the style in the ACP and hard reset your browsers cache.

The above goes before the </head> tag in the file
Appreciate the extensions/mods/support then buy me a beerImage
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
kirkt02
Registered User
Posts: 32
Joined: Sun Sep 30, 2012 8:59 pm

Re: How do i get links to open in new window.

Post by kirkt02 »

Mick wrote:
kirkt02 wrote:Is is int there some kind of code that can be added in a temple or somthing, i honestly do not know what that means at all, and nothing is explained how to do it.
Whatever instructions you're following will have code to be added somewhere or other. What are you following that has no instructions? If it's the KB linked to previously there are plenty of explicit instructions.

Most instructions on phpBB.com for adding code, be it a full blown MOD or a KB article, tell you exactly what to do. Usually all you have to do is open a file (using a GOOD text editor), search for a certain piece code and then follow what it says to do once you've found the piece of code, it's just copying and pasting.

Yeah but that dose not explain anything either, why are there no step by step directions on how to download and install the things you need.
I dont even know where to find what has to be downloaded let alone trying to adjust, then re-upload it again.

whats a good text editor mean, i tried filezillia and smart ftp before and got no where with it. There are no tutorials? I honestly can not see why you do not have hundreds of people complaining about this.. all this to get a a link to open in a new tab???

How do they expect people to do this stuff without proper instructions.. so what ever person that has a phpbb board has to be a mind reader. Well that just part a a article that dont help or direct you on how to do squat now is it???

RMcGirr83 wrote:If you are using the jQuery library this code placed in your overall_header.html file after the jQuery library stuffs will open all external links in a new window

Code: Select all

<script type="text/javascript">
$(function(){

	var source = removeSubdomain(location.hostname);
	$('a[href^="http://"], a[href^="https://"]').filter(function() {return this.hostname && removeSubdomain(this.hostname) !== source;}).attr('target', '_blank');
});
</script>
and if you don't have the jQuery library loaded in your overall_header.html file place this before the above

Code: Select all

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
then refresh the style in the ACP and hard reset your browsers cache.

The above goes before the </head> tag in the file
well hopefully somethingli9ke this is more what i am looking for.
Not sure what you mean by jquery library but will see if i can try to figure it out.



RMcGirr83 wrote:
then refresh the style in the ACP and hard reset your browsers cache.
You mean refresh the template? i dont have a refresh for style?
also what is a hard rest for browser cache?
Last edited by kirkt02 on Mon Dec 03, 2012 6:25 pm, edited 1 time in total.
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 51553
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: How do i get links to open in new window.

Post by stevemaury »

This IS a step-by-step tutorial - https://www.phpbb.com/kb/article/links- ... w-windows/

Good text editor would be, for example, Notepad++. It is free - Google it.
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
kirkt02
Registered User
Posts: 32
Joined: Sun Sep 30, 2012 8:59 pm

Re: How do i get links to open in new window.

Post by kirkt02 »

stevemaury wrote:This IS a step-by-step tutorial - https://www.phpbb.com/kb/article/links- ... w-windows/

Good text editor would be, for example, Notepad++. It is free - Google it.

i have note pad, word, other software, it is the downloading and uploading to the server stuff i have no clue I already have the link to that page, it is not giving me directions on how to find what i need to download what where in the acp, and how to re-up.

i dont have the first clue where i am supported to find what i need to download?
User avatar
stevemaury
Support Team Member
Support Team Member
Posts: 51553
Joined: Thu Nov 02, 2006 12:21 am
Location: The U.P.
Name: Steve
Contact:

Re: How do i get links to open in new window.

Post by stevemaury »

Not Note Pad, not Word - Notepad++. Nowhere in that article does it mention the ACP. This has nothing to do with the ACP. Use FTP to download the named files from your server. Edit. Upload.

How about a link to your board?
For REALLY good and VERY inexpensive hosting CLICK HERE

I can stop all your spam. I can upgrade or update your Board. PM or email me. (Paid support)
User avatar
RMcGirr83
Former Team Member
Posts: 21492
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr

Re: How do i get links to open in new window.

Post by RMcGirr83 »

kirkt02 wrote:You mean refresh the template? i dont have a refresh for style?
also what is a hard rest for browser cache?
Yes refresh the template...a "hard browser reset" means to reset your browsers cache which is usually done with a CTRL + F5 for most browsers (with Chrome you have to go into the tools section of chrome to clear the browsers cache).

And whatever you do do not use notepad or word to edit files with use notepad++ for editing and filezilla (your host can help you with setting up filezilla if need be) client (google for both they are free) to download and upload into your forum. Take your time...the first time always seems the most difficult but you'll get there will some patience and perseverance.
Appreciate the extensions/mods/support then buy me a beerImage
Former Modifications/Extensions Team Member | My extensions | github | All requests for support via PM will be ignored
User avatar
Cpt. Blackbeard
Registered User
Posts: 443
Joined: Sat Oct 31, 2009 4:39 am
Location: USA
Contact:

Re: How do i get links to open in new window.

Post by Cpt. Blackbeard »

Few things tick me off faster than a link opening in a new Window, if I want a new Window I'll right click and choose it, otherwise I open a few links and suddenly discover I have a half dozen new Windows open. I rtend to avoid those sites like the plague
User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: How do i get links to open in new window.

Post by Oyabun1 »

There is lots of information on this site about how to do things, you just have to look for it. For example, Tools needed to set up and customise phpBB, gives suggestions for appropriate tools, such as a text editor. FileZilla is a FTP client not a text editor.

For terms that you are not sure of rather than complaining that you don't know it is usually quicker and easier to spend a few seconds searching, you can usually find an explanation, for example, browser hard reset.

You really should ask your users what they prefer before making changes to the board. You may think that links opening in a new window is a good idea, but they may not agree.
Cpt. Blackbeard wrote:if I want a new Window I'll right click and choose it,
Or you can just Ctrl + click for a new window or shift + click for a new tab.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests
guardianwill
Registered User
Posts: 128
Joined: Sat Feb 25, 2006 3:26 am

Re: How do i get links to open in new window.

Post by guardianwill »

Hi Kirk, hope all is going well. If your still looking for a reasonable way to have a url in a post open up in a new window, have you tried creating a new bbcode? I simply created a new bbcode and use it. I think I call it urlblank. I believe you can also turn off the origianl url as well. Maybe call it newurl or something you think is easy enough. It works for me.

Code: Select all

usage:
[urlnew={URL}]{TEXT}[/urlnew]

replacement:
<a href={URL} target="_blank">{TEXT}</a>

Help:
[urlnew=Url Link for example http://phpbb.com]What you want them to see and click as a link[/urlnew]
Well, if you have things going as you like sorry so late in suggesting. If it can be of use--great!

Happy Holidays

William
kirkt02 wrote:Hi i am having a problem getting links to open in a new window.
Every link that is click opens in the same window. so people have to do a back click to get back to the forum and mopst are just closing the window thuis closeing the forum out.

I was reading this over here.
https://www.phpbb.com/kb/article/links- ... w-windows/

for Modifying auto-detected links

and it tell syou to find this

Code: Select all

    $html    = "$whitespace<!-- $tag --><a$class href=\"$url\">$text</a><!-- $tag -->$append";
and replace with this.

Code: Select all

        if ($type == MAGIC_URL_EMAIL)
        {
            $html    = "$whitespace<!-- $tag --><a$class href=\"$url\">$text</a><!-- $tag -->$append";    
        }
        else 
        {
            $html    = "$whitespace<!-- $tag --><a$class href=\"$url\" onclick=\"window.open(this.href);return false;\">$text</a><!-- $tag -->$append";
        } 
but it is not telling me where to find it. it says around line 592? what template ??? hahah :lol:

I dont want the bbcode thing, i just want people to be able to post a link, and when clicked it opens in a new window links should open a new window by default, you go to any website or forum they all do. phpbb has to be complicated, it's silly
People are leaving because they closing the darn windows out and it closing the forum, so they are getting aggravated on closing the windows out all the time by habbit
User avatar
Oyabun1
Former Team Member
Posts: 23162
Joined: Sun May 17, 2009 1:05 pm
Location: Australia
Name: Bill

Re: How do i get links to open in new window.

Post by Oyabun1 »

guardianwill wrote:Hi Kirk ... have you tried creating a new bbcode?
kirkt02 wrote:... I dont want the bbcode thing, i just want people to be able to post a link, and when clicked it opens in a new window links should open a new window by default ...
Also, using target="_blank" will mean any page using those links will not be XHTML valid. For a BBCode it would be better to use

Code: Select all

<a href="{URL}" onclick="window.open(this.href);return false;">{TEXT}</a>
as the HTML replacement, then the page will validate.
                      Support Request Template
3.0.x: Knowledge Base Styles Support MOD Requests
3.1.x: Knowledge BaseStyles SupportExtension Requests
Locked

Return to “[3.0.x] Support Forum”