Open a new tab

Frances McDonald January 1, 2014

Within a page and you have a "link" to another page I would like this page to open a new window/tab each time. I understand you can right click on the link and "open in ew tab" option but most people just click on the link and it uses the same page hence to view the instructions/content you have to back space each time. I would like an link to open a new page automatically. I belioeve this may not be good practise for certain reason so can you advise if it is good practise and how it can be done thanks..

2 answers

1 vote
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 3, 2014

you can try like this

<script>
jQuery(document).ready(function() {
	if(AJS.$('#confluence-space-key').attr('content') == 'TO'){
		AJS.$(".wiki-content a").attr("target", "_blank");
	}

});
</script>

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 5, 2014

if my answers helped then don't forgot to accept as answer:)

Frances McDonald January 5, 2014

thank you this was the resolution and if statement for a space key..

Davin Studer
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 19, 2014

One slight edit that would future proof this a little would be to use the AJS.Meta.get method to get the space key.

<script>
jQuery(document).ready(function() {
    if(AJS.Meta.get("space-key") == 'TO'){
        AJS.$(".wiki-content a").attr("target", "_blank");
    }
 
});
</script>

0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 1, 2014
Frances McDonald January 1, 2014

thanks for this..

Is there a way I can do it for a certain space key only rather than whole look and feel..can I amend the html code for just a certain space please..thanks

Frances McDonald January 1, 2014

tried to edit the target space details and chose space admin. I do not see anyway of choosing "custom html" within this space only under the Look and Feel

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 1, 2014

it will be on Administration >> Custom HTML not on the target space details.

if you don't have administration permission then ask your confluence administartor to add the script

Frances McDonald January 1, 2014

but will this change the issue for all spaces..I only want to do it for a space for my area and not the complete look and feel for all spaces ?thanks

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 1, 2014

You'll need to put an "if" statement into the javascript to detect the current space and only activate if it matches the spaces you need it for.

For what it's worth though, opening in a new window/tab every time is a royal pain in the neck for most users as you quickly litter their workspaces with pages they don't care about any more. It should be used sparingly, not on every link.

Frances McDonald January 1, 2014

but where will the if statement lie within here if the Space key is called "TO":

<script>
jQuery(document).ready(function() {
jQuery(".wiki-content a").attr("target", "_blank");
});
</script>
Frances McDonald January 2, 2014

can someone tell me how to put an "if" statement to the script please if spacekey is called "TO"

RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2014

if you provide UI source code of space key then i can able to help you, because i don't confluence on my machine!!

Frances McDonald January 2, 2014
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 2, 2014

use firebug on firefox or JavaScript console on chrome and get the HTML code for that link

or

press Ctrl + u it will give source code of entaire page, from that you can copy the html code for that link

Frances McDonald January 2, 2014
<html>
<head>
<title>Welcome to Technology Operations - Technology Operations - Wonga Wiki</title>
<meta http-equiv="X-UA-Compatible" content="IE=EDGE,chrome=IE7">
<meta charset="UTF-8">
<!-- Deprecated since 3.4. To be removed in a future version of Confluence; use AJS.Confluence.getContextPath() -->
<meta id="confluence-context-path" name="confluence-context-path" content="">
<meta id="confluence-base-url" name="confluence-base-url" content="http://wiki.wonga.com">
<meta id="atlassian-token" name="atlassian-token" content="69a6a0c404663e80828d3067ad47341ff39fc514">
<meta id="confluence-space-key" name="confluence-space-key" content="TO">
<script type="text/javascript">
// Deprecated global variables. To be removed in a future version of Confluence.
var contextPath = '';
</script>
Frances McDonald January 2, 2014

from cntrl u

<link rel="canonical" href="http://wiki.wonga.com/display/TO/Welcome+to+Technology+Operations">
<link rel="shortlink" href="http://wiki.wonga.com/x/xY3pAw">
Frances McDonald January 2, 2014
Frances McDonald January 2, 2014

I also tried to add this statement

#if (AJS.params.spaceKey == 'TO')

to what you suggested as space key is TO na ddidnt work..

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events