Confluence 2.5.6 : How do I make my attachments open in a new window or a tab?
This page last changed on Apr 19, 2007 by ivan@atlassian.com.
Cannot resolve external resource into attachment. How do I make my attachments open in a new window/tab?You need to add a TARGET = "_blank" to the <a href> HTML tag. The A element used in HTML denotes an anchor which is a hypertext link. <Source: http://www.w3.org/TR/html401/struct/links.html > For example, by using the HTML code below, clicking on the link "a new window" will open the "newwindow.html" page in a new window: <A href="newwindow.html" _TARGET="_blank"_>a new window</A> Open attachments listed for a SpaceTo open the attachments listed from the Browse Space->Attachments tab, in a new window, the ..\confluence\src\webapp\pages\listattachmentsforspace.vm file under your <Confluence-install> directory has to be modified. Below are the listed steps: 1. Locate the following block of code in the listattachmentsforspace.vm file: foreach ($attachment in $pagedAttachments) <tr #alternateRowColors() id="attachment_$attachment.id"> <td width="1%" nowrap valign="top"><a name="$generalUtil.urlEncode($attachment.content.realTitle)-attachment-$generalUtil.urlEncode($attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$attachment.downloadPathWithoutVersion" >$attachment.fileName</a></td> <td width="1%" nowrap valign="top">$attachment.niceFileSize</td> <td width="1%" nowrap valign="top">#usernameLink($attachment.creatorName) #if ($attachment.creatorName!=$attachment.lastModifierName) ($action.getText('last.modified.by') #usernameLink($attachment.lastModifierName)) #end</td> <td width="1%" nowrap valign="top">$dateFormatter.format($attachment.lastModificationDate)</td> <td>#contentLink2 ($attachment.getContent() true false)</td> </tr> #end 2. In the line below: <td width="1%" nowrap valign="top"><a name="$generalUtil.urlEncode($attachment.content.realTitle)-attachment-$generalUtil.urlEncode($attachment.fileName)"> #parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$attachment.downloadPathWithoutVersion" >$attachment.fileName</a></td> add the parameter TARGET = "_blank" to the <a href> HTML tag, which will cause the URL specified in the href parameter to open in a new window or a new tag depending upon the option set in the browser. So the line above will be modified to: <td width="1%" nowrap valign="top"><a name="$generalUtil.urlEncode($attachment.content.realTitle)-attachment-$generalUtil.urlEncode($attachment.fileName)"> #parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$attachment.downloadPathWithoutVersion" *TARGET = "_blank"*>$attachment.fileName</a></td> Open attachments listed for a PageTo open the page attachments listed from the Page's Attachment(s) tab, in a new window, the ..\confluence\src\webapp\pages\viewattachments.vm file under your <Confluence-install> directory has to be modified. Below are the listed steps: 1. Locate the following block of code in the viewattachments.vm file: <td nowrap valign="top"><a name="$generalUtil.htmlEncode($generalUtil.urlEncode($page.title))-attachment-$generalUtil.htmlEncode($generalUtil.urlEncode($attachment.fileName))">#parse ("/pages/includes/attachment_icon.vm")</a> <a href="$generalUtil.htmlEncode(" ${req.contextPath}${attachment.downloadPathWithoutVersion}")"TARGET = "_blank">$generalUtil.htmlEncode($attachment.fileName)</a></td> 2. In the line below: <a name="$generalUtil.htmlEncode($generalUtil.urlEncode($page.title))-attachment-$generalUtil.htmlEncode($generalUtil.urlEncode($attachment.fileName))"> #parse ("/pages/includes/attachment_icon.vm")</a> <a href="$generalUtil.htmlEncode(" ${req.contextPath}${attachment.downloadPathWithoutVersion}")">$generalUtil.htmlEncode($attachment.fileName)</a> add the parameter TARGET = "_blank" to the <a> HTML tag, which will cause the URL specified in the href parameter to open in a new window or a new tag depending upon the option set in the browser. So the line above will be modified to: <a name="$generalUtil.htmlEncode($generalUtil.urlEncode($page.title))-attachment-$generalUtil.htmlEncode($generalUtil.urlEncode($attachment.fileName))"> #parse ("/pages/includes/attachment_icon.vm")</a> <a href="$generalUtil.htmlEncode(" ${req.contextPath}${attachment.downloadPathWithoutVersion}")" TARGET = "_blank">$generalUtil.htmlEncode($attachment.fileName)</a> |
![]() |
Document generated by Confluence on Oct 10, 2007 18:36 |