Page 1 of 1
Open related documents in new tab
Posted: 12 Feb 2018
by Oz.Ab
Hæhæ,
In the display and edit form I need to be able to click the related documents and open them in a new tab (or new window) in the browser. Because the user needs to be able to have the form and the doucment open at the same time.
By default when I am in display/edit form, when I click the related documents they will open in the same window - and I can't find anything about this in the forum :/
Regards
Re: Open related documents in new tab
Posted: 12 Feb 2018
by Nikita Kurguzov
Dear Oz,
This shouldn't be the case - by default all items in Related Items are opened in dialog mode. Which version of SharePoint and Forms Designer are you using? Are there any console errors when you open Related Items' form?
Can you, please, provide us some screenshots or even better a video?
Re: Open related documents in new tab
Posted: 13 Feb 2018
by Oz.Ab
Thanks for the quick reply.
If I open related items, they open in dialog.
If I open related documents (word, excel etc), they open in the same window. I want the documents to open in a new tab in the browser or a new window
Re: Open related documents in new tab
Posted: 14 Feb 2018
by Nikita Kurguzov
Dear Oz,
You can try to add the following code to open documents in a new tab:
Code: Select all
$("a[onclick*='return DispEx'][target!='_blank']")
.attr("target", "_blank")
.removeAttr("onclick");
// document type icons
$("td.ms-vb-icon>img[onclick]:not([documentUrl])")
.click(function (e)
{
window.open($(this).attr("documentUrl"), "_blank");
e.stopPropagation();
e.preventDefault();
return false;
})
.each(function ()
{
$(this).attr(
"documentUrl",
$.trim(String($(this).attr("onclick"))
.split("=")[1]
.replace(/["'{}]/g, "")
.split(";")[0])
);
this.onclick = null;
});