Вопрос

Это похоже, что это должно быть легкой, но это не работает так, как я этого ожидаю.У меня есть сайт SharePoint 2010 с библиотекой документов, которая содержит несколько словных документов.Установлены веб-приложения Office, и настройка по умолчанию для фермы - открыть документы Word в браузере.

Когда я нажимаю на ссылку документа в представлении списка Allitems.aspx, он открывается в браузере (по желанию).Однако, если я нажму на тот же документ в CQWP на другой странице, он всегда предлагает скачать документ.Как я могу заставить CQWP открыть документы Word в браузере?

Это было полезно?

Решение

Apparently this is a known issue.

I've got two possible solutions for you.

1) Enable the "Open documents in client applications by default" site collection feature (from MSDN):

http://social.msdn.microsoft.com/Forums/en/sharepointgeneralprevious/thread/90d251c3-43d4-4b05-b87c-7c25bb32a782

2) Modify the XSL to open the document in a new browser window (from the SharePoint Developer Team blog):

http://blogs.technet.com/b/sharepointdevelopersupport/archive/2012/07/24/how-to-open-content-query-web-part-links-in-a-new-ie-window.aspx

Другие советы

For those wondering exactly what I did, I had to edit the ItemStyle.xsl file in the Style Library of my site. In the xsl template for this particular instance of the CQWP, I created a variable called $SiteUrl (I'm not entirely sure I needed to do this, as I am relatively new to this stuff):

<xsl:variable name="SiteUrl">
  <xsl:value-of select="substring-before($SafeLinkUrl,'/Lists/')"/>
</xsl:variable>

Then I leveraged that variable inside of the anchor tag like so:

<div style="position:relative; float:left; padding-right:10px;">
  <a onfocus="OnLink(this)" href="{$SafeLinkUrl}" onmousedown="return VerifyHref(this,event,'1','SharePoint.OpenDocuments','1{$SiteUrl}/_layouts/WordViewer.aspx?id={$SafeLinkUrl}')" onclick="return DispEx(this,event,'TRUE','FALSE','FALSE','SharePoint.OpenDocuments.3','1','SharePoint.OpenDocuments','','1{$SiteUrl}/_layouts/WordViewer.aspx?id={$SafeLinkUrl}','','1','0','0','0x7fffffffffffffff','','')" target="{$LinkTarget}" title="{@LinkToolTip}" class="CQWPHeader" >
    <xsl:if test="$ItemsHaveStreams = 'True'">
      <xsl:attribute name="onclick">
        <xsl:value-of select="@OnClickForWebRendering"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
      <xsl:attribute name="onclick">
        <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>
      </xsl:attribute>
    </xsl:if>
    <xsl:value-of select="$DisplayTitle"/>
  </a>
</div>

This did the trick for me. If necessary, I suppose I could have used an to look at the file extension and open the Excel viewer for .xls/x files, but that wasn't required for my project.

I found that the Search Results Web Part has an "Open in Browser" option and works. I abandoned both the CQWP and CSWP for this.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с sharepoint.stackexchange
scroll top