HOW TO: Open Content Query Web Part links in a new IE window

This post is a contribution from Charls Tom Jacob, an engineer with the SharePoint Developer Support team.

Content Query Web Part is a nice way to query and display data from multiple lists.  By default, when you click on a link displayed in the Content Query Web Part, it opens up in the same IE browser window.  This can be annoying at times if users want to stay on the main page and view the items in a different IE browser window.

In this post, I’ll describe how to extend the out of the box Content Query Web Part and the styles such that links open in new IE window.

Step1: Extend out of the box XSL

  1. Download the out of the box ItemStyle.xsl from Style Library (go to Site Actions –> View all site content –> Style Library –> XSL Style Sheets).
  2. Rename the file to ItemStyleExtended.xsl.
  3. Open the file in NOTEPAD, locate the <DIV> element that acts as a container for links displayed in the web part:
  4. <div class=”link-item”>

  5. Modify the following anchor tag to open the links in a new window:
  6. <a href="{$SafeLinkUrl}" title="{@LinkToolTip}">


    <a href="{$SafeLinkUrl}" title="{@LinkToolTip}" target="_blank">

  7. Comment out the XSL that performs an additional check for links to documents or other file types, as below:
  8. <!--<xsl:if test="$ItemsHaveStreams = 'True'">
           <xsl:attribute name="onclick">
              <xsl:value-of select="@OnClickForWebRendering"/>
         <xsl:if test="$ItemsHaveStreams != 'True' and @OpenInNewWindow = 'True'">
            <xsl:attribute name="onclick">
               <xsl:value-of disable-output-escaping="yes" select="$OnClickTargetAttribute"/>

  9. Upload the new file to Style Library.

Step2:  Extending the Content Query Web Part

  1. Open the Web Part page that contains the Content Query Web Part.
  2. Export the web part, save it as “Extented_Content_Query.webpart”.
  3. Open the web part file in NOTEPAD, modify the following:
  4. a. Set the title property to "Extended Content Query"
        <property name="Title" type="string">Extended Content Query</property>
    b. Set the XSLItemLink to the uploaded XSL style sheet file:
        <property name="ItemXslLink" type="string">/Style%20Library/XSL%20Style%20Sheets/ItemStyleExtended.xsl</property>

  5. Upload the extended Content Query Web Part to web part gallery.
  6. Add the extended Content Query Web Part to the web part page.
  7. Point the web part source to a document library in the site.
  8. Click on a link to verify that it opens in a new IE window.

Hope this helps!

Comments (4)
  1. Good solution. I was wondering if this worked with MOSS, but the changes in the ItemStyle are a little beyond me. Do you think this will work with SharePoint 2013?

  2. Amby says:

    There is no style sheet in the Style Library. Is there another place it might be located or so? Thanks

  3. Jeff says:

    Thank you! This was very helpful and worked well in SP 2013. Anyone following the above steps will want to make sure to use <!– instead of <!- to comment out the additional XSL, or you will receive an error.

    1. Jeff says:

      My comment is not displaying properly… if you type two dash (-) marks, this page will only display one… hence making the “comment out” in step 5 and also in my comment, display incorrectly.

Comments are closed.

Skip to main content