SQL Server Reporting Services - Opening up hyperlink in a new window

Published 28 January 08 11:17 | Simon Phillips

By default if you create a navigation link in Reporting Services it opens the link in the same window. In the majority of cases this is fine as you usually use these for navigating to bookmarks within the same report or other reports. However there are many times that you would want to open the link in a new window, say opening up a customers site. The problem with the default behaviour is that it will open in the same window and you will loose the report being shown. You can hit the back button on the browser but this, unless you're using execution or snap-shot cache, will re-run the report.

If your report is being rendered as a web page you can modify your Navigation expression to use the JavaScript function window.open.

e.g.

="j avascript:void(window.open('{url}','_blank'));"

Wrapping the window.open function with a void is good practice as tells the browser not to expect anything back from from the JavaScript.

You could also extend this to use a name window or even specify the dimension of the window. If you need help on windows.open the head over to these web sites

One word of warning that these links will only work with the report being rendered in HTML,if you render in PDF or Excel then you really need to keep the links as a url without the JavaScript. At this time I haven't worked out how to determine, programmatically, the rendering option.

Comments

# Simon Phillips said on January 28, 2008 11:40 :

Had to add a space in the code example because CS, detected that this was a script and modifed the output with a big BLOCKED SCRIPT text :S.

# John Tyce said on February 8, 2008 02:41 :

I get the following error: Colons and line terminators are not valid in expressions

# Reporting Services Reports in a new window « Charlie Maitland’s Blog said on September 22, 2008 11:09 :

Pingback from  Reporting Services Reports in a new window « Charlie Maitland’s Blog