Add link to R Shiny Application so link opens in a new browser tab

Chris picture Chris · Jul 25, 2013 · Viewed 25.6k times · Source

I am creating my first Shiny Application in R. I am using shiny to display bivariate results from a survey I conducted. From a pair of input boxes users can choose variables from the survey, and various statistics are generated (tables, plots, etc.) allowing them to explore certain attributes of the survey data.

I want to include a link to the actual PDF survey. Right now I have written code so that the PDF survey can be linked to, by clicking on the text "Click here to download survey" which appears as helpText, embedded in a wellPanel, within the pageWithSidebar. I used the following commands (in the ui.R file):

    wellPanel(
    helpText(   a("Click Here to Download Survey",     href="http://www.dfcm.utoronto.ca/Assets/DFCM2+Digital+Assets/Family+and+Community+Medicine/DFCM+Digital+Assets/Faculty+$!26+Staff/DFCM+Faculty+Work+$!26+Leadership+Survey+Poster.pdf")
    )
    )

Is there a way to automatically open this file in a new tab (of IE, Firefox, etc.)? Currently, the functionality is to open the link in the same tab as the shiny app. So you have to use the forward and backwards buttons to go from app to survey and back again.

Right now, I am right clicking the link and selecting "Open in a New Tab". Is there a way to embed this functionality into the back end code so it becomes the default.

Disclaimer: I have no real experience in html or java. I am an avid user of R. If a solution is possible, can you please try to explain where I embed the code changes in the ui.R or server.R files respectively.

Answer

Chris picture Chris · Jul 25, 2013

Adding the argument target="_blank" to the function a() worked perfectly. Thanks for the solution @Chase!!