Open related documents in new tab

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
Oz.Ab
Posts: 39
Joined: Mon Oct 09, 2017

12 Feb 2018

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 :)

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

12 Feb 2018

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?
Cheers

Oz.Ab
Posts: 39
Joined: Mon Oct 09, 2017

13 Feb 2018

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 :)

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

14 Feb 2018

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;
  });
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 17 guests