Quite often we will be writing custom XSL to customize the display of a Content Query Web Part (CQWP) and at times we would want to get the current page URL where the CQWP web part lives. For example, providing a link to a custom page to display your item as shown below, where the “Details” link is pointing to a custom page.
However, you would like to be able to get back to the origin page where the link is clicked. You could achieve this by doing the following in your custom XSL:
Step 1: Add the following namespace to your custom XSL:
xmlns:ddwrt=”http://schemas.microsoft.com/WebParts/v2/DataView/runtime
Step 2: Add a parameter name “PageUrl” right after XSL Stylesheet declaration:
<xsl:param name=”PageUrl” />
Step 3: Add a query string to the link:
Step 4: Add a link or button on your custom page and the following OnClick event: